Server. mappath () related

Source: Internet
Author: User

Reprinted: http://blog.sina.com.cn/s/blog_8216ada70100t4p1.html

1.Server. mappath ()Introduction

Server. mappath (string path) is used to returnWebThe physical file path corresponding to the specified virtual path on the server. Its ParametersPathIsWebThe Virtual Path of the server. The returned result isPathThe corresponding physical file path. However, sometimes the parameter is not a virtual path, but a custom file name.

Server. mappath ()The full name isSystem. Web. httpcontext. Current. server. mappath (). Sometimes inProgramDuring debugging, the system prompts "the current context does not have a name."Server""Error. Therefore, the function is not supported.Server. mappath (). Although the namespace"Using system. Web;"Does not help, so you need to use its full name, or the current useServer. mappath ()The class of the function inherits fromSystem. Web. UI. Page.

2.Server. mappath ()Application

Server. mappath (""): Returns the path of the physical file on the current page.

Server. mappath ("/"): Returns the physical file path of the application root directory.

Server. mappath ("./"): Returns the path of the physical file on the current page.

Server. mappath ("../"): Returns the path of the physical file at the upper level of the current page.

Server. mappath ("~ /"): Return the virtual directory (PATH) of the application)

Server. mappath ("~ "): Return the virtual directory (PATH) of the application)

3.Note:Server. mappath ()The returned results may be different in different environments. As shown in the preceding sixServer. mappath ()Application.Vs2010During the test, the second and fourth items will prompt the error "ing path failed", but when changing the position of the program, only the second item will prompt an error. Therefore, different software and environments have different support levels.

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.