Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request.RawUrl vs. Request.Url

Tags:

asp.net

What is the difference between Request.RawUrl and Request.Url in ASP.NET?

like image 696
kerbou Avatar asked Jan 07 '10 11:01

kerbou


People also ask

What is Rawurl?

The raw URL is defined as the part of the URL following the domain information. In the URL string http://www.contoso.com/articles/recent.aspx , the raw URL is /articles/recent. aspx. The raw URL includes the query string, if present.

How do I get a raw URL?

How can I get the raw URL for these files? You can just type the name of the file at the end of the path. Get the URL for your text file and replace the filename/path with the path to your datafile. Cyverse might be a little easier since you should be able to upload a single directory of your hub data (including hub.


1 Answers

No one seems to have mentioned that it shows the Raw URL actually received by IIS, before any manipulation may have happened sending it around IIS or your file system with URL rewriting for example.

Say you have set an error page at /error in an MVC app and you set your webconfig to replace error pages with your custom error page at that location. In this way when getting an error at /faultypage, the user will get the page at /error but the url in your browser's address bar will still say www.mysite.com/faultypage—this is a transfer, or a rewrite.

Now on your error controller if you are to take a peek at Request.Url, it will be something like www.mysite.com/error and Request.RawUrl would say (more usefully?) /faultypage which is the user's actual request not the page that is currently being executed.

like image 152
BritishDeveloper Avatar answered Sep 27 '22 20:09

BritishDeveloper