The preceding two methods return the path D: \ wwwroot \ company \ news \ show. asp.
Differences between Server. MapPath () and Request. MapPath () in ASP. NET:
Server. MapPath (string): maps the files (or directories) of the currently called files to physical paths;
Request. MapPath (string): ing the string virtual path to the physical path (Request does not have this method in asp)
In server. mappath (string), the string can reference the parent directory in the "../" mode, or even jump this directory out of the entire web directory, such as: C: \ wwwroot
The directory is the web root directory. You can call this server. mappath ("../xyz.gif") in the root directory file to call scripts and resources outside the web directory.
Request. the string in mappath (string) is a virtual directory, which can only be in the form of a Web virtual directory and cannot be ".. /"method call, can only be"/","/xx "and other strings
Sometimes it is difficult to directly use server. mappath (string) to call a file, because different directories call the same server. mappath (string) function to obtain different values,
In special cases, you must determine the directory level to obtain the correct address. You can call the same directory file by using request. mappath (string. No directory judgment required
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.