Asp. NET Relative Path Usage Summary _ Practical skills

Source: Internet
Author: User
If there is a path to the picture on the Web site is this: http://localhost:2008/websit1/images/1.jpg

WEBSIT1 represents a virtual path or a site

In asp.net, if we enter Response.Write (Request.mappath ("/01.jpg") in the. CS page;

This can output the physical path of the picture, which is the exact path to the image on the server.

Relative paths in HTML
Copy Code code as follows:

... /indicates switching to the previous level directory Http://localhost:2008/01.jpg
./or do not fill in the current path http://localhost:2008/websit1/01.jpg
/indicates that the root directory returns the root directory of the Web site http://localhost:2008/01.jpg

~/can only be used in asp.net and can only be used in server controls

If it is a site or a virtual directory, it represents the root directory.
Copy Code code as follows:

Response.Write (Request.maoppath ("~/01.jpg")) obtained is Response.Write (Request.mappath ("/01.jpg")); The same physical path

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.