About the acquisition of physical path and virtual path in asp.net __net

Source: Internet
Author: User

Request.currentexecutionfilepath; The virtual path for the current request is this format:/virtual directory name/admin/index.aspx
Request.applicationpath//Gets the virtual application root path of the ASP.net application on the server. /virtual directory name (application name)

These are the file paths in the virtual directory, which is the path in IIS. To get the real physical path is to be added on the basis of the above path:
Server.MapPath (Request.applicationpath + "splconfig/classmap.xml")//This may have a bug

It's better that way.
String M_applicationpath=request.applicationpath;
if (this.m_applicationpath== "")
This.m_applicationpath= "/";
if (!this.m_applicationpath.endswith ("/"))
This.m_applicationpath + = "/"; Let's judge for a moment.
Server.MapPath (m_applicationpath+ "Splconfig/classmap.xml")

2005 new access Methods for address URLs
This. Request.currentexecutionfilepath; The path in the virtual busy of the current request
This.  Request.filepath; Paths in the virtual directory
This.  Request.PhysicalPath; The physical path of the current request
This. request.physicalapplicationpath;//the 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 ());

Refreshing of custom methods

This. Response.Redirect (this. Request.currentexecutionfilepath + "depid=" + this.hDepID.Value.ToString ());

Note: Original from: http://blog.csdn.net/szwangdf/archive/2007/05/08/1600480.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.