Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Default ASPX form in virtual directory?

Reply
Thread Tools

Default ASPX form in virtual directory?

 
 
Usenet User
Guest
Posts: n/a
 
      09-17-2008
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:

http://mysite/mydir/

instead of

http://mysite/mydir/MyPage.aspx

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.aspx" 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!

 
Reply With Quote
 
 
 
 
George
Guest
Posts: n/a
 
      09-18-2008
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 <form> with 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 <form> and
then ASP.NET will not override it.


George.


"Usenet User" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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:
>
> http://mysite/mydir/
>
> instead of
>
> http://mysite/mydir/MyPage.aspx
>
> 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.aspx" 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!
>


 
Reply With Quote
 
 
 
 
Norm
Guest
Posts: n/a
 
      09-18-2008
On Sep 17, 10:05*pm, "George" <(E-Mail Removed)> wrote:
> 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 <form> with 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 <form> and
> then ASP.NET will not override it.
>
> George.
>
> "Usenet User" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
> > 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:

>
> >http://mysite/mydir/

>
> > instead of

>
> >http://mysite/mydir/MyPage.aspx

>
> > 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.aspx" 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?ItemID=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
 
Reply With Quote
 
Usenet User
Guest
Posts: n/a
 
      09-18-2008
On Thu, 18 Sep 2008 01:05:04 -0400, "George" <(E-Mail Removed)>
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 <form> with 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.__smartNav.attachForm in
aspnet_client\system_web\1_1_4322\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 <form> and
>then ASP.NET will not override it.
>
>
>George.
>


Thanks!
 
Reply With Quote
 
George
Guest
Posts: n/a
 
      09-19-2008
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
http://georgeplusnet.blogspot.com/20...on-part-7.html

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

In ASP.NET 3.5 <FORM> object 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.action="";

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


George.


"Norm" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...


George,

I have a similar situation involving url rewritten links. ("/Item/
1.aspx" = "/Item.aspx?ItemID=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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to return the full virtual path if I pass the url as "~/default.aspx"? ABC ASP .Net 2 03-27-2006 08:43 AM
Why is Default.aspx not present in the Default Content page? Gaetan ASP .Net 3 02-14-2006 07:24 PM
adding main.aspx.vb & main.aspx.resx under aspx John M ASP .Net 1 05-29-2005 09:27 PM
WebForm1.aspx / default.aspx Ted Apollo ASP .Net 5 08-26-2004 10:18 PM
default.aspx or login aspx? Armando Ruiz MCAD 0 06-22-2004 03:39 PM



Advertisments