Summary of using relative paths in ASP. NET

Source: Internet
Author: User

If the path of an image on a website is http: // localhost: 2008/websit1/images/1.jpg

Websit1 indicates a virtual path or site

In asp.net, if we enter Response. Write (Request. MapPath ("/01.jpg") on the. cs page "));

This can output the physical path of the image, that is, the specific path of the image stored on the server.

Relative Path in HTML
Copy codeThe Code is as follows:
../indicates switching to the upper-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 website's root directory http: // localhost: 2008/01. jpg

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

If it is a site or virtual directory, it indicates the root directory.
Copy codeThe Code is as follows:
Response. Write (Request. MaopPath ("~ /01.jpg") is returned as Response. Write (Request. MapPath ("/01.jpg"); the same physical path

Related Article

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.