Set the full address of the current page to: http://www.jb51.net/aaa/bbb.aspx? Id = 5 & name = kelli
"Http: //" is the protocol name.
"Www.jb51.net" is a domain name
"Aaa" is the site name
"Bbb. aspx" is the page name (file name)
"Id = 5 & name = kelli" is a parameter
[1] obtain the complete url (protocol name + domain name + site name + file name + parameter)
Copy codeThe Code is as follows:
String url = Request. Url. ToString ();
Url = http://www.jb51.net/aaa/bbb.aspx? Id = 5 & name = kelli
[2] retrieve site name + Page name + parameters:
Copy codeThe Code is as follows:
String url = Request. RawUrl;
(Or string url = Request. Url. PathAndQuery ;)
Url =/aaa/bbb. aspx? Id = 5 & name = kelli
[3] retrieve site name + Page name:
Copy codeThe Code is as follows:
String url = HttpContext. Current. Request. Url. AbsolutePath;
(Or string url = HttpContext. Current. Request. Path ;)
Url = aaa/bbb. aspx
[4] retrieve domain names:
Copy codeThe Code is as follows:
String url = HttpContext. Current. Request. Url. Host;
Url = www.jb51.net
[5] GET parameters:
Copy codeThe Code is as follows:
String url = HttpContext. Current. Request. Url. Query;
Url =? Id = 5 & name = kelli
Copy codeThe Code is as follows:
Request. RawUrl: Get the URL Information of the client Request (excluding the host and port) ------>/Default2.aspx
Request. ApplicationPath: Obtain the virtual path of ASP. NET applications on the server. ------>/
Request. CurrentExecutionFilePath: Obtain the virtual path of the current Request. ------>/Default2.aspx
Request. Path: Obtain the virtual Path of the current Request. ------>/Default2.aspx
Request. PathInfo: obtain the additional path information of the resource with the URL extension ------>
Request. PhysicalPath: Obtain the physical file system path corresponding to the requested URL. ------> E: \ temp \ Default2.aspx
Request. Url. LocalPath: ------>/Default2.aspx
Request. Url. AbsoluteUri: ------ & gt; http: // localhost: 8080/Default2.aspx
Request. Url. AbsolutePath: ---------------------------->/Default2.aspx