Default ASPX form in virtual directory?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Usenet User

    Default ASPX form in virtual directory?

    Platform: IIS 5 or 6, ASP .NET 1.1

    I can configure default page for my virtual directory and "hide" that
    page from users. For example, if I have an ASPX from called
    MyPage.aspx, I can make it default, so it can be omitted from URL:



    instead of



    The problem I see is that even if the user uses the "short" URL, on
    the postback he gets redirected to the full URL. This is because
    "MyPage.asp x" is used a the form's target tag in the generated HTML
    code. Such behavior defies the purpose and also, I believe, messes up
    the ViewState on the first postback due to redirect.

    Is there a good way to avoid the above issues and make sure the the
    "short" URL is preserved throughout postbacks?

    Thanks!

  • George

    #2
    Re: Default ASPX form in virtual directory?

    There is no redirect involved so nothing messes up the ViewState.
    IIS silently replaces the request http://mysite/mydir/ with
    http://mysite/mydir/MyPage.aspx and there is no way for ASP.NET to know that
    the short url was hit.
    Then ASP.NET populates the action property of the <formwith currently hit
    page i.e. default.aspx

    There is no way to fix it in ASP.NET 1.1 (May be there is but a tricky one
    and i do not know it).
    Starting ASP.NET 3.5 you can specify empty action property of the <formand
    then ASP.NET will not override it.


    George.


    "Usenet User" <no.spam@no.way wrote in message
    news:rqs2d41g6s kh7js2ukojl0p2t 4lpnl3ujf@4ax.c om...
    Platform: IIS 5 or 6, ASP .NET 1.1
    >
    I can configure default page for my virtual directory and "hide" that
    page from users. For example, if I have an ASPX from called
    MyPage.aspx, I can make it default, so it can be omitted from URL:
    >

    >
    instead of
    >

    >
    The problem I see is that even if the user uses the "short" URL, on
    the postback he gets redirected to the full URL. This is because
    "MyPage.asp x" is used a the form's target tag in the generated HTML
    code. Such behavior defies the purpose and also, I believe, messes up
    the ViewState on the first postback due to redirect.
    >
    Is there a good way to avoid the above issues and make sure the the
    "short" URL is preserved throughout postbacks?
    >
    Thanks!
    >

    Comment

    • Norm

      #3
      Re: Default ASPX form in virtual directory?

      On Sep 17, 10:05 pm, "George" <noem...@comcas t.netwrote:
      There is no redirect involved so nothing messes up the ViewState.
      IIS silently replaces the requesthttp://mysite/mydir/withhttp://mysite/mydir/MyPage.aspxand there is no way for ASP.NET to know that
      the short url was hit.
      Then ASP.NET populates the action property of the <formwith currently hit
      page i.e. default.aspx
      >
      There is no way to fix it in ASP.NET 1.1 (May be there is but a tricky one
      and i do not know it).
      Starting ASP.NET 3.5 you can specify empty action property of the <formand
      then ASP.NET will not override it.
      >
      George.
      >
      "Usenet User" <no.s...@no.way wrote in message
      >
      news:rqs2d41g6s kh7js2ukojl0p2t 4lpnl3ujf@4ax.c om...
      >
      Platform: IIS 5 or 6, ASP .NET 1.1
      >
      I can configure default page for my virtual directory and "hide" that
      page from users. For example, if I have an ASPX from called
      MyPage.aspx, I can make it default, so it can be omitted from URL:
      >>
      instead of
      >>
      The problem I see is that even if the user uses the "short" URL, on
      the postback he gets redirected to the full URL.  This is because
      "MyPage.asp x" is used a the form's target tag in the generated HTML
      code.  Such behavior defies the purpose and also, I believe, messes up
      the ViewState on the first postback due to redirect.
      >
      Is there a good way to avoid the above issues and make sure the the
      "short" URL is preserved throughout postbacks?
      >
      Thanks!
      George,

      I have a similar situation involving url rewritten links. ("/Item/
      1.aspx" = "/Item.aspx?ItemI D=1") Postbacks will automatically post to
      the "internal" page, not the rewritten one. Can you provide more
      information about this feature in APS.NET 3.5? Thx in advance.

      -Norm

      Comment

      • Usenet User

        #4
        Re: Default ASPX form in virtual directory?

        On Thu, 18 Sep 2008 01:05:04 -0400, "George" <noemail@comcas t.net>
        wrote:
        >There is no redirect involved so nothing messes up the ViewState.
        Sorry, by redirect I meant that the original short URL is replaced by
        the full URL via form's action, so on the first postback the user goes
        to a different URL. The ViewState *can* be affected. I have a form
        that erases itself on the first postback, if the short URL is used.
        Not sure why this is happening. Just built another, simpler form, and
        that one behaves correctly...
        >IIS silently replaces the request http://mysite/mydir/ with
        >http://mysite/mydir/MyPage.aspx and there is no way for ASP.NET to know that
        >the short url was hit.
        Ouch! That is really the barrier... Indeed, both Request.Url and
        Request.RawUrl contain the actual page name, even if the short URL was
        used.
        >Then ASP.NET populates the action property of the <formwith currently hit
        >page i.e. default.aspx
        >
        >There is no way to fix it in ASP.NET 1.1 (May be there is but a tricky one
        >and i do not know it).
        Well, SmartNavigation ="true" seem to help (see
        window.__smartN av.attachForm in
        aspnet_client\s ystem_web\1_1_4 322\SmartNav.js ), but I would not rely
        on that 100%. The same stubborn form mentioned above does not work as
        intended.

        In theory, if the real URL the user used was discoverable, form's
        action could be overridden in Page rendering events somewhere. But it
        would be too much hassle, I think. (One "hacky" way to pass the URL
        to the server is to grab window.location .href in Javascript and store
        it in a server-side hidden control.)
        >Starting ASP.NET 3.5 you can specify empty action property of the <formand
        >then ASP.NET will not override it.
        >
        >
        >George.
        >
        Thanks!

        Comment

        • George

          #5
          Re: Default ASPX form in virtual directory?

          Yes, it's a common problem with UrlRewriting.
          There are several ways to solve the problem.

          I had described the solution in my blog post
          Url rewriting. Nowdays, every web developer bows to Google and Yahoo. And that is right. Who wants/needs to spend it's time and get the per...


          I would recommend to go through all 7 posts. You might find them
          interesting.

          In ASP.NET 3.5 <FORMobject has a property "action" now which will not be
          overwritten by ASP.NET. So you can simply set it to "" it will generate
          <from action=""HTML.
          So put it into your OnLoad event this.Page.actio n="";

          Also I believe you can set it declaratively in the page itself
          <form action="" runat=server>


          George.


          "Norm" <neonorm@gmail. comwrote in message
          news:621f722a-fdee-4dc3-9714-f9189ca27890@w1 g2000prk.google groups.com...


          George,

          I have a similar situation involving url rewritten links. ("/Item/
          1.aspx" = "/Item.aspx?ItemI D=1") Postbacks will automatically post to
          the "internal" page, not the rewritten one. Can you provide more
          information about this feature in APS.NET 3.5? Thx in advance.

          -Norm

          Comment

          Working...