[Note] If you are familiar with the URL, please do not have to look down. If you are not familiar with it, please refer to it for reference. Because you often need to obtain URL-related information in asp.net, although various methods are listed on msdn, there are too many methods and attributes to remember them one by one. In this example, parameters related to paths and file information are listed in a method, for normal access.
Using System;
Using System. Data;
Using System. Configuration;
Using System. Collections;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. Web. UI. WebControls. WebParts;
Using System. Web. UI. HtmlControls;
Public partial class AjaxDemo: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
Response. Write ("Request. AppRelativeCurrentExecutionFilePath =" + Request. AppRelativeCurrentExecutionFilePath + "<br> ");
Response. Write ("Request. CurrentExecutionFilePath =" + Request. CurrentExecutionFilePath + "<br> ");
Response. Write ("Request. FilePath =" + Request. FilePath + "<br> ");
Response. Write ("Request. Path =" + Request. Path + "<br> ");
Response. Write ("Request. PathInfo =" + Request. PathInfo + "<br> ");
Response. Write ("Request. PhysicalApplicationPath =" + Request. PhysicalApplicationPath + "<br> ");
Response. Write ("Request. PhysicalPath =" + Request. PhysicalPath + "<br> ");
Response. Write ("Request. RawUrl =" + Request. RawUrl + "<br> ");
Response. Write ("Request. Url =" + Request. Url + "<br> ");
Response. Write ("Request. UrlReferrer =" + Request. UrlReferrer + "<br> ");
Response. Write ("Request. UserHostAddress =" + Request. UserHostAddress + "<br> ");
Response. Write ("Request. UserHostName =" + Request. UserHostName + "<br> ");
Uri uri = Request. Url;
Response. Write ("uri. AbsolutePath =" + uri. AbsolutePath + "<br> ");
Response. Write ("uri. AbsoluteUri =" + uri. AbsoluteUri + "<br> ");
Response. Write ("uri. Authority =" + uri. Authority + "<br> ");
Response. Write ("uri. Host =" + uri. Host + "<br> ");
Response. Write ("uri. HostNameType =" + uri. HostNameType + "<br> ");
Response. Write ("uri. Scheme =" + uri. Scheme + "<br> ");
Response. Write ("uri. LocalPath =" + uri. LocalPath + "<br> ");
Response. Write ("uri. OriginalString =" + uri. OriginalString + "<br> ");
Response. Write ("uri. PathAndQuery =" + uri. PathAndQuery + "<br> ");
Response. Write ("uri. Port =" + uri. Port + "<br> ");
Response. Write ("uri. Segments = ");
Foreach (string str in uri. Segments)
{
Response. Write (str + ",");
}
}
}
The front-end does not have any controls. The webpage path is http: // localhost: 4336/Web/AjaxDemo. aspx. The final output result is as follows:
Request. AppRelativeCurrentExecutionFilePath = ~ /AjaxDemo. aspx
Request. CurrentExecutionFilePath =/Web/AjaxDemo. aspx
Request. FilePath =/Web/AjaxDemo. aspx
Request. Path =/Web/AjaxDemo. aspx
Request. PathInfo =
Request. PhysicalApplicationPath = D:/SXJST/Web/
Request. PhysicalPath = D:/SXJST/Web/AjaxDemo. aspx
Request. RawUrl =/Web/AjaxDemo. aspx
Request. Url = http: // localhost: 4336/Web/AjaxDemo. aspx
Request. UrlReferrer =
Request. UserHostAddress = 127.0.0.1
Request. UserHostName = 127.0.0.1
Uri. AbsolutePath =/Web/AjaxDemo. aspx
Uri. AbsoluteUri = http: // localhost: 4336/Web/AjaxDemo. aspx
Uri. Authority = localhost: 4336
Uri. Host = localhost www.2cto.com
Uri. HostNameType = Dns
Uri. Scheme = http
Uri. LocalPath =/Web/AjaxDemo. aspx
Uri. OriginalString = http: // localhost: 4336/Web/AjaxDemo. aspx
Uri. PathAndQuery =/Web/AjaxDemo. aspx
Uri. Port = 4336
Uri. Segments =/, Web/, AjaxDemo. aspx,
From the field of hope