I decided to write down and document for myself the different paths provided by ASP.NET, to get a grip on the subject and a reference to turn to.
The path I will be requesting is:
http://www.myurl.com/MyApplication/MyFolder/MyPage.aspx?QueryStringKey=QueryStringValue
This will be an ASP.NET-application named MyApplication in the IIS.
Request-reference
Here is the result returned by the Request
-property of the page, which is a
HttpRequest.
Request.ApplicationPath:
/MyApplication
- Gets the ASP.NET application's virtual application root path on the server.
Request.AppRelativeCurrentExecutionFilePath:
~/MyFolder/MyPage.aspx
- Gets the virtual path of the application root and makes it relative by using the tilde (~) notation for the application root (as in "~/page.aspx").
Request.CurrentExecutionFilePath:
/MyApplication/MyFolder/MyPage.aspx
- Gets the virtual path of the current request.
Request.FilePath:
/MyApplication/MyFolder/MyPage.aspx
- Gets the virtual path of the current request.
Request.Path:
/MyApplication/MyFolder/MyPage.aspx
- Gets the virtual path of the current request.
Request.PathInfo:
- Gets additional path information for a resource with a URL extension.
Request.PhysicalApplicationPath:
C:\Visual Studio Projects\MyApplication\
- Gets the physical file system path of the currently executing server application's root directory.
Request.PhysicalPath:
C:\Visual Studio Projects\MyApplication\MyFolder\MyPage.aspx
- Gets the physical file system path corresponding to the requested URL.
Request.RawUrl:
/MyApplication/MyFolder/MyPage.aspx?QueryStringKey=QueryStringValue
- Gets the ASP.NET application's virtual application root path on the server.
Request.Url-reference
Then there is the property
Request.Url
that returns a
System.Uri
, with all its properties. This is an interesting thing to explore as well.
Request.Url.AbsolutePath:
/MyApplication/MyFolder/MyPage.aspx
- Gets the absolute path of the URI.
Request.Url.AbsoluteUri:
http://www.myurl.com/MyApplication/MyFolder/MyPage.aspx?QueryStringKey=QueryStringValue
- Gets the absolute URI.
Request.Url.DnsSafeHost:
www.myurl.com
- Gets an unescaped host name that is safe to use for DNS resolution.
Request.Url.Host:
www.myurl.com
- Gets the host component of this instance.
Request.Url.LocalPath:
/MyApplication/MyFolder/MyPage.aspx
- Gets a local operating-system representation of a file name.
Request.Url.OriginalString:
http://www.myurl.com:80/MyApplication/MyFolder/MyPage.aspx?QueryStringKey=QueryStringValue
- Gets the original URI string that was passed to the Uri constructor.
Request.Url.PathAndQuery:
/MyApplication/MyFolder/MyPage.aspx?QueryStringKey=QueryStringValue
- Gets the AbsolutePath and Query properties separated by a question mark (?).
Request.Url.Query:
?QueryStringKey=QueryStringValue
- Gets any query information included in the specified URI.
Request.Url.ToString():
http://www.myurl.com/MyApplication/MyFolder/MyPage.aspx?QueryStringKey=QueryStringValue
- Gets a canonical string representation for the specified Uri instance.
Request
also has the property
Request.UrlReferrer
which is of the type System.Uri
and has the same properties as Request.Url
. It has the following description:
Gets information about the URL of the client's previous request that linked to the current URL.