Possible error / issue in ASP.NET 3.5 related to Request.RawUrl property

I sent a request for 301-redirect using ASP.NET 3.5 here:

Redirecting default.aspx to the root virtual directory

Based on the answers I received there, I realized that there might be an error in the ASP.NET Request.RawUrl method, which cannot return the actual raw URL (without / default.aspx) when used in a subdirectory, i.e. the /default.aspx page is inside a subdirectory.

Can someone shed light on this possible mistake?

Thanks,

Asif

+4
source share
3 answers

If you suspect that this is an error, then the place to go is Microsoft Connect , where you can report and discuss the error directly using Microsoft.

Edit: I was able to reproduce the look of your comments.

However, I could not reproduce the endless loop. I injected the code into the Global.asax Application_BeginRequest handler of the web application and got the expected behavior of a single redirect.

There are others, and IMOs are much better options for handling global forwarding rules. In IIS7, I use the Rewrite URL module to configure rewrite rules in IIS. You can learn more about this and download it here: http://www.iis.net/download/urlrewrite . The appeal of this solution is that you can customize and update your rewrite rules without recompiling the application.

Edit: I was able to get the raw URL without default.aspx (after the redirect), using instead:

 Request.ServerVariables["CACHE_URL"] 

It's worth it.

+1
source

Have you looked at the IIS settings for your virtual directory? If there is a default document set to default.aspx then this will explain the infinite loop you are experiencing. You tell the website to redirect to the virtual directory without "default.aspx", and IIS detects this on the next request and returns it ad infinitum.

Right-click your virtual directory, select Properties, and then the Documents tab. If default.aspx is listed, then this is what you get. The request URL will be passed to the ASP.NET workflow as /folder/default.aspx, not / folder /

It's not a mistake. If IIS did not do this, you will receive an error message that was not found.

It seems to me that you need to investigate the rewriting of the URL : http://msdn.microsoft.com/en-us/library/ms972974.aspx

0
source

All Articles