When programming in Asp.net,
Image files and style sheets are often referenced.
Generally, because your Aspx is in various folders at different levels,
Therefore, the reference to the same file is often changed
Href = ".../../CSS/style.css"
Href = ".../../CSS/style.css"
And so on,
Each time a reference is added, the number of levels in the directory is required,
It is painful.
In fact,
There is a simple way to solve this problem at one time:
1. Add the images and CSS folders to the project root directory,
And transfer the corresponding file
2. Add a new site (such as helloworld) to IIS ),
This site points to your Asp.net project,
The site has a custom port, such as 9998.
3. Now, all references to images and style sheets can be written as follows:
/CSS/style.css
/CSS/admin.css
/Images/logo.gif
/Images/submit.gif
That is, the referenced style sheets and images are stored in the CSS and imges folders in the root directory,
Instead of using a lot of ../to indicate the path.
Now, your style sheets and images can take effect at runtime (http: // localhost: 9998,
However, images and style sheets cannot be found in the development environment.
4. Modify the projectname. csproj. webinfo file of the project,
Change urlpath to http: // localhost: 9998/projectname. csproj
Congratulations! Now, your style sheets and images can take effect in the development environment!