Summary of the use of relative paths in ES0en. NET
- 2020-06-23 00:10:50
- OfStack
If you have a pictures on the website of the path is this: http: / / localhost: 2008 / websit1 images / 1. jpg
websit1 represents a virtual path or site
In asp.net, if we enter Response.Write (Request.MapPath ("/ 01.jpg ") on the.cs page;
This will output the physical path of the image which is the specific path that the image will take on the server
Relative paths in HTML
And ~/ can only be used in ES26en.net and only in server controls
If it is a site or virtual directory, it represents the root directory
websit1 represents a virtual path or site
In asp.net, if we enter Response.Write (Request.MapPath ("/ 01.jpg ") on the.cs page;
This will output the physical path of the image which is the specific path that the image will take on the server
Relative paths in HTML
<img src=" ../01.jpg"> ../ Means switch to up 1 Level directory http://localhost:2008/01.jpg
<img src=" ./01.jpg"> ./ or Don't fill in Represents the current path http://localhost:2008/websit1/01.jpg
<img src=" /01.jpg"> / Represents the root directory This returns the root directory of the site http://localhost:2008/01.jpg
And ~/ can only be used in ES26en.net and only in server controls
If it is a site or virtual directory, it represents the root directory
Response.Write(Request.MaopPath("~/01.jpg")) Is obtained by Response.Write(Request.MapPath("/01.jpg")); Same physical path