Obtain physical and virtual paths in ASP. NET
// Request. currentexecutionfilepath; the virtual path of the current request is in this format:/virtual directory name/admin/index. aspx
// Request. applicationpath // obtain the root path of the virtual application of ASP. NET applications on the server. /Virtual directory name (Application name)
The above are the file paths in the virtual directory, that is, the paths in IIS. To obtain a real physical path, you must add the following to the above path:
Server. mappath (request. applicationpath + "splconfig/classmap. xml") // This may cause a bug.
This is the best practice.
String m_applicationpath = request. applicationpath;
If (this. m_applicationpath = "")
This. m_applicationpath = "/";
If (! This. m_applicationpath.endswith ("/"))
This. m_applicationpath + = "/"; // first judge/
Server. mappath (m_applicationpath + "splconfig/classmap. xml ")
2005 new URL access method
// This. Request. currentexecutionfilepath; // the path in the virtual busy state of the current request
// This. Request. filepath; // path in the virtual directory
// This. Request. physicalpath; // physical path of the current request
// This. Request. physicalapplicationpath; // physical path of the application
// This. Request. url. absoluteuri; // All URLs
Request. rawurl get URL with variable request. urlreferrer get URL without variable
How to refresh this page:
This. response. Redirect (this. Request. url. absoluteuri, true );
This. response. Redirect (this. Request. url. tostring ());
Refresh custom methods
This. response. Redirect (this. Request. currentexecutionfilepath + "? Depid = "+ this. hdepid. value. tostring ());