Set current page full address is: 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 station roll call
"Bbb.aspx" is the name of the page (file name)
"Id=5&name=kelli" is a parameter
"1" To get the full URL (protocol name + domain name + site names + filename + parameters)
Copy Code code as follows:
String url=request.url.tostring ();
Url= Http://www.jb51.net/aaa/bbb.aspx?id=5&name=kelli
"2" Get Site name + page name + parameter:
Copy Code code 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:
Copy Code code as follows:
String Url=httpcontext.current.request.url.absolutepath;
(or string url= HttpContext.Current.Request.Path;)
Url= aaa/bbb.aspx
"4" Get the domain name:
Copy Code code as follows:
String Url=httpcontext.current.request.url.host;
Url= www.jb51.net
"5" Get the parameters:
Copy Code code as follows:
String Url= HttpContext.Current.Request.Url.Query;
Url=? Id=5&name=kelli
Copy Code code as follows:
Request.rawurl: Gets the URL information requested by the client (excluding host and port)------>/default2.aspx
Request.applicationpath: Gets the virtual path of the ASP.net application on the server. ------>/
Request.currentexecutionfilepath: Gets the virtual path of the current request. ------>/default2.aspx
Request.path: Gets the virtual path of the current request. ------>/default2.aspx
Request.pathinfo: Additional path information for a resource with a URL extension------>
Request.PhysicalPath: Gets the physical file system path that corresponds to the requested URL. ------>e:\temp\default2.aspx
Request.Url.LocalPath:------>/default2.aspx
Request.Url.AbsoluteUri:------>http://localhost:8080/default2.aspx
Request.Url.AbsolutePath:---------------------------->/default2.aspx