Several ways to get a Web path

Source: Internet
Author: User
Tags servervariables

1, String str1 = Request.ApplicationPath.ToString (); The return path is: \holterclientweb

2, HttpServerUtility. MapPath method Explanation: returns the physical file path corresponding to the virtual path specified on the WEB server.

String path=Server.MapPath(Request.applicationpath + "/upload/reportfile");

After commissioning:

String str3= Server.MapPath ("./");

c:\\users\\administrator\\desktop\\holterclientweb\\filehandle\\

String str4= Server.MapPath (".. /");

c:\\users\\administrator\\desktop\\holterclientweb\\

String STR5 = Server.MapPath ("~/");

c:\\users\\administrator\\desktop\\holterclientweb\\

Additional:

./Current directory
/website Home directory
    .. /Upper Directory
~/Web site virtual directory

3, String exe = HttpContext.Current.Server.MapPath("Pdf2swf.exe");

After commissioning:

4, String str6 = Server.MapPath (request.servervariables["Path_info"]);

5, String str7 = request.servervariables["path_translated"];

Other reference address: http://blog.csdn.net/ecdyf1989/article/details/5877648

Http://www.cnblogs.com/leixiaoling/archive/2012/03/30/2425466.html

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.