Many people write code when the problem of the path is very headache, in fact, the path is very simple, but no one to help us point to vote! The first learning process, I am sure will encounter and I have the same problem, for example, "/" and "~" to quote the difference between brutishness, next see, this article will definitely will you point, read this article you will have a situations, vista feeling!
[Note:] Bo master: jkxx123321 Welcome friends and I exchange problems, explore learning, I am now full stack of net MVC and RN
1, about the path:
(1) Absolute path
Path containing the site path: <a href= "Http://www.baidu.com/about.jpg" > Baidu </a>
Site change path failure;
(2) Relative path
Same directory: <a href= "About.jpg" ></a>
The parent directory is the same: <a href= ". /about.jpg "></a>
Parent directory with High: <a hrf= ". /.. /about.jpg "></a>
(3) Root Path
A compromise between a relative path and an absolute path, starting with/
<a href= "/about/about.jpg" ></a>
2. About paths in ASP.
(1) ~ for the Web application root operator, only in server code, not in the client element;
(2) src= "@Url. Content (" ~/scripts/*.js ")" Converts the virtual path to the absolute path of the site, and if not, returns only the path string;
If the program is located under HTTP://WWW.AAA.COM/BBB, src= "@Url. Content (" ~/scripts/*.js ")" translates to:
Http://www.aaa.com/bbb/scripts/*.js
src= "/scripts/*.js" translates to:
Http://www.aaa.com/scripts/*.js
(3) MVC3 must write src= "@Url. Content (" ~/scripts/*.js ")"
And MVC4 can be written directly as src= "~/scripts/*.js"
3. Add references in ASP.
(1) Adding CSS Links
<link href= "@Url. Content (" ~/content/site.css ")" rel= "Stylesheet" type= "Text/css"/>
(2) Add an external script reference
<script src= "@Url. Content (" ~/scripts/jquery-1.7.1.min.js ")" Type= "Text/javascript" ></script>
Of course, this is only for net, if the development in other languages will encounter other problems, refueling!
Path doubts in ASP. NET MVC