Physical path on the server disk: HttpRuntime. AppDomainAppPath
Virtual Program path:
HttpRuntime. AppDomainAppVirtualPath
Any method related to Request/HttpContext. Current can only be used when there is a Request context or page.
That is, when no request context is available, HttpContext. Current is null, and the method mentioned above is always available.
The access to global Cache objects is also true.
Private
Void responseHtml ()
...{
System. Text. StringBuilder sb = new
System. Text. StringBuilder ();
Sb. Append (string. Format ("Current time:
{0 }",
Server. HtmlEncode (DateTime. Now. ToString ())));
Sb. Append ("<br/> ");
Sb. Append (string. Format ("virtual path of the current request:
{0} ", Server. HtmlEncode (Request. CurrentExecutionFilePath )));
Sb. Append ("<br/> ");
Sb. Append (string. Format ("obtain the root directory path of the current application: {0 }",
Server. HtmlEncode (Request. ApplicationPath )));
Sb. Append ("<br/> ");
Sb. Append (string. Format ("virtual path of the current request:
{0} ", Server. HtmlEncode (Request. FilePath )));
Sb. Append ("<br/> ");
Sb. Append (string. Format ("virtual path of the current request:
{0} ", Server. HtmlEncode (Request. Path )));
Sb. Append ("<br/> ");
Sb. Append (string. Format ("obtain the physical file system path of the root directory of the currently running application: {0 }",
Server. HtmlEncode (Request. PhysicalApplicationPath )));
Sb. Append ("<br/> ");
Sb. Append (string. Format ("Get and request URL
Corresponding physical file system path: {0 }",
Server. HtmlEncode (Request. PhysicalApplicationPath )));
Sb. Append ("<br/> ");
Response. Write (sb. ToString ());
}
}
Output: Current time: 2007-08-30
11:03:49
The virtual path of the current request:/aDirectory/Sample/responseHtml. asp tutorial x
Obtain the root directory path of the current application:
/ADirectory
The virtual path of the current request:/aDirectory/Sample/responseHtml. aspx
The virtual path of the current request:
/ADirectory/Sample/responseHtml. aspx
Obtain the physical file system path of the root directory of the currently running application: E: Visual
Maxcompute Studio 2005
Obtain the physical file system path corresponding to the requested URL: E: Visual Studio 2005 aDirectory
When the url contains parameters, you can use:
HttpContext. Current. Request. Url. PathAndQuery. ToString ()//
This page address: Request. URL;
Last page address:
Request. UrlReferrer
Request. ServerViables ["http_referer"]
Request. RawUrl
Request. RawUrl. QueryAndPath
System. IO. Path. GetFileName (Request. FilePath. ToString ())