user11850 user11850 - 1 month ago 13
ASP.NET (C#) Question

Request.RawUrl vs. Request.Url

What is the difference between

Request.RawUrl
and
Request.Url
in ASP.NET?

Answer

From MSDN:

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.

This means, you can use rawurl and do not have to care about through which address the server was called (for instance http://yourserver/ or http://yourserver.yourdomain.com/ if you have multiple interfaces.)

However, the URL property of an HTTPRequest object returns a System.URI object, which also contains server name.