Tag: The AAA and string htm sample gets the tostring www. Asp
Assume the full address of the current page is: Http://www.jbxue.com/aaa/bbb.aspx?id=5&name=kelli
The
"/HTTP" is the protocol name
"Www.jbxue.com" is the domain name
"AAA" is the station name.
"Bbb.aspx" is the page name (file name)
"Id=5&name=kelli" is a parameter
Here are some examples of the relevant parameters in the URL, including the full URL, domain name and other information.
1, get the full URL (protocol name + domain + site name + file name + parameters)
Copy Codecode example: String url=request.url.tostring ();
Url= Http://www.jbxue.com/aaa/bbb.aspx?id=5&name=kelli
2, Get Site name + page name + parameters:
Copy Codecode example: String Url=request.rawurl;
(or string url=request.url.pathandquery;)
Url=/aaa/bbb.aspx?id=5&name=kelli
3, Get Site name + page name:
Copy Codecode example: String Url=httpcontext.current.request.url.absolutepath;
(or string url= HttpContext.Current.Request.Path;)
Url= aaa/bbb.aspx
4, get the domain name:
Copy Codecode example: String Url=httpcontext.current.request.url.host;
Url= www.jbxue.com
5, Get Parameters:
Copy Codecode example: String Url= HttpContext.Current.Request.Url.Query;
Url=? Id=5&name=kelli
2017-8-25 C # Five ways to get URL parameters (go)