This article is a mirror article of machine translation, please click here to jump to the original article.

View: 14126|Reply: 0

[ASP.NET] asp.net get the URL address of the current page

[Copy link]
Posted on 6/7/2015 6:36:04 PM | | |
The full address of the current page is:http://www.itsvse.com/aaa/bbb.aspx?id=5&name=kelli
"http://" is the name of the agreement
"www.itsvse.com" is the domain name
"AAA" is the site name
"bbb.aspx" is the page name (file name)
"id=5&name=kelli" is the parameter
[1] Get the full URL (protocol name + domain name + site name + file name + parameters)

The code is as follows:

string url=Request.Url.ToString();
url=http://www.itsvse.com/aaa/bbb.aspx?id=5&name=kelli

[2] Get the site name + page name + parameters:

The code is as follows:

string url=Request.RawUrl;
(or string url=Request.Url.PathAndQuery; )
url= /aaa/bbb.aspx?id=5&name=kelli

[3] Get the site name + page name:

The code is as follows:

string url=HttpContext.Current.Request.Url.AbsolutePath;
(or string url= HttpContext.Current.Request.Path; )
url= aaa/bbb.aspx

[4] Obtain a domain name:

The code is as follows:

string url=HttpContext.Current.Request.Url.Host;
url=www.itsvse.com

[5] Get the parameters:

The code is as follows:

string url= HttpContext.Current.Request.Url.Query;
url= ?id=5&name=kelli




The code is as follows:

Request.RawUrl: Gets the URL information of the client request (excluding the host and port) ------>/Default2.aspx
Request.ApplicationPath: Gets the virtual path to ASP.NET application on the server. ------>/
Request.CurrentExecutionFilePath: Gets the virtual path to the current request. ------>/Default2.aspx
Request.Path: Get the virtual path to the current request. ------>/Default2.aspx
Request.PathInfo: Takes additional path information for resources with a URL extension ------>
Request.PhysicalPath: Gets the physical file system path corresponding to the URL of the request. ------>E:\temp\Default2.aspx
Request.Url.LocalPath:------>/Default2.aspx
Request.Url.AbsoluteUri:------>http://localhost:8080/Default2.aspx
Request.Url.AbsolutePath:---------------------------->/Default2.aspx






Previous:Baidu Japan search engine was closed and was discovered a month later
Next:The source code is encrypted with DES for the C# program password
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com