1. Simple Environment Setup
A Web site is configured on local IIS: Host name is wjnhome.com, Port 88, and then a virtual directory is built to point to the same site, virtual directory name, and configure host as 127.0.0.1 wjnhome.com
So the address is: http://jb51.net:88/virtual/urldemo.aspx?id=2#top
2. Write Simple code
Copy Code code as follows:
Path to virtual directory
Response.Write ("<strong>Request.ApplicationPath:</strong>" + Request.applicationpath + "</br>");
Physical path of the site (full path)
Response.Write ("<strong>Request.PhysicalPath:</strong>" + Request.PhysicalPath + "</br>");
Directory of site Physical path
Response.Write ("<strong>DirectoryName:</strong>" + System.IO.Path.GetDirectoryName ( Request.PhysicalPath) + "</br>");
Directory of site Physical path
Response.Write ("<strong>Request.PhysicalApplicationPath:</strong>" + Request.physicalapplicationpath + "</br>");
The file name of the current page
Response.Write ("<strong>FileName:</strong>" + System.IO.Path.GetFileName (Request.PhysicalPath) + "< /br> ");
Virtual path for current page
Response.Write ("<strong>Request.CurrentExecutionFilePath:</strong>" + Request.currentexecutionfilepath + "</br>");
Virtual path for current page
Response.Write ("<strong>Request.FilePath:</strong>" + Request.filepath + "</br>");
Response.Write ("<strong>Request.Path:</strong>" + Request.path + "</br>");
Original URL
Response.Write ("<strong>Request.RawUrl:</strong>" + Request.rawurl + "</br>");
Absolute path (excluding parameters or whatever)
Response.Write ("<strong>Request.Url.AbsolutePath:</strong>" + Request.Url.AbsolutePath + "</br>") );
Absolute URL
Response.Write ("<strong>Request.Url.AbsoluteUri:</strong>" + Request.Url.AbsoluteUri + "</br>");
URL Protocol Scheme
Response.Write ("<strong>Request.Url.Scheme:</strong>" + Request.Url.Scheme + "</br>");
Host name of the URL
Response.Write ("<strong>Request.Url.Host:</strong>" + Request.Url.Host + "</br>");
URL Port number
Response.Write ("<strong>Request.Url.Port:</strong>" + Request.Url.Port + "</br>");
Host name + port number
Response.Write ("<strong>Request.Url.Authority:</strong>" + Request.Url.Authority + "</br>");
Gets the local operating system representation of the file name
Response.Write ("<strong>Request.Url.LocalPath:</strong>" + Request.Url.LocalPath + "</br>");
Additional path information, such as Http://jb51.net:88/UrlDemo.aspx/Hello?id=22#top so here's Hello.
Response.Write ("<strong>Request.PathInfo:</strong>" + request.pathinfo + "</br>");
Path and get parameters for URL
Response.Write ("<strong>Request.Url.PathAndQuery:</strong>" + Request.Url.PathAndQuery + "</br>") );
Get parameter for URL
Response.Write ("<strong>Request.Url.Query:</strong>" + Request.Url.Query + "</br>");
Mainly refers to the top in the back of the http://jb51.net:88/UrlDemo.aspx/Hello?id=22#top.
However, the value cannot normally be obtained because the browser will not send this value to the server side
Response.Write ("<strong>Request.Url.Fragment:</strong>" + Request.Url.Fragment + "</br>");
Host Name
Response.Write ("<strong>Request.Url.DnsSafeHost:</strong>" + Request.Url.DnsSafeHost + "</br>");
All of the URLs
Response.Write ("<strong>Request.Url.OriginalString:</strong>" + Request.Url.OriginalString + "</BR") > ");
This condition Uri uriaddress = new Uri ("Http://user:password@www.contoso.com/index.htm") Console.WriteLine ( Uriaddress.userinfo);
Response.Write ("<strong>Request.Url.UserInfo:</strong>" + Request.Url.UserInfo + "</br>");
The value of the source page is displayed when you jump from a page.
Response.Write ("<strong>Request.UrlReferrer:</strong>" + request.urlreferrer + "</br>");
Each segment of the URI
for (var i = 0; i < request.url.segments.length;i++)
{
Response.Write ("<strong>request.url.segment" + i + ":</strong>" + request.url.segments[i] + "</br>") ;
}
3. Output results
Request.applicationpath:/virtual
Request.physicalpath:e:\vsproject\201200420\urldemo\urldemo\urldemo.aspx
Directoryname:e:\vsproject\201200420\urldemo\urldemo
Request.physicalapplicationpath:e:\vsproject\201200420\urldemo\urldemo\
FileName:urldemo.aspx
Request.currentexecutionfilepath:/virtual/urldemo.aspx
Request.filepath:/virtual/urldemo.aspx
Request.path:/virtual/urldemo.aspx
request.rawurl:/virtual/urldemo.aspx?id=2
Request.url.absolutepath:/virtual/urldemo.aspx
request.url.absoluteuri:http://jb51.net:88/virtual/urldemo.aspx?id=2
Request.Url.Scheme:http
Request.Url.Host:wjnhome.com
request.url.port:88
request.url.authority:wjnhome.com:88
Request.url.localpath:/virtual/urldemo.aspx
Request.pathinfo:
request.url.pathandquery:/virtual/urldemo.aspx?id=2
request.url.query:?id=2
Request.Url.Fragment:
Request.Url.DnsSafeHost:wjnhome.com
request.url.originalstring:http://jb51.net:88/virtual/urldemo.aspx?id=2
Request.Url.UserInfo:
Request.urlreferrer:
request.url.segment0:/
request.url.segment1:virtual/
Request.Url.Segment2:urldemo.aspx
Author: wjn