Ram*_*ran 14 c# browser asp.net url path
我有一个脚本文件.
<script src="~/Scripts/angular.js"></script>
Run Code Online (Sandbox Code Playgroud)
看路径是~/Script.但是,如果我输入../../而不是~/,此过程也是一样的.
我的网站网址如下: https://sample.com/Scripts/angular.js
如果我../../之前进入Scripts,那么它会自动更改以前的URL (https://sample.com/Scripts/angular.js).
什么是网址流程?它怎么能自动改变?请告诉我们之间的区别
./, ../ , ../../ , ~/ ,/Scripts ,Scripts?
Dav*_*vid 23
这些路径组件是具有特定含义的快捷方式:
.表示当前路径级别(因此,如果您打开index.aspx并且您引用,./style.css则后者必须与前者位于同一文件夹中)..意味着一个路径升级(所以如果你打开/somefolder/index.aspx并且你引用../style.css那么后者必须在父文件夹中someFolder)/根级别(因此/style.css是相同的http://www.mysite.com/style.css)~ 在ASP.NET中意味着服务器端应用程序根(因此~/index.aspx将被转换为应用程序根目录中的index.aspx文件的URL )这里有很多事情需要注意:
~.这只能在服务器端组件中预处理的路径中使用.然后,服务器端组件将知道基于应用程序相对于Web服务器的当前位置将其转换为客户端可见路径...)没有限制.根的父级被视为根.所以,如果你在上面http://www.mysite.com/someFolder/index.aspx,你会参考../../../../style.css它http://www.mysite.com/style.css.../somePage.aspx,但当您用鼠标将鼠标悬停在它上面时,浏览器会指示它是http://www.mysite.com/somePage.aspx.这是因为浏览器已将前者的相对路径转换为后者的绝对路径.opa*_*ela 17
让我们来看看...
. = this directory
.. = the parent directory
../ = the parent directory
~/ = the user's home directory or the application's, in ASP
/ = the root directory
../../ = the parent's parent directory
Run Code Online (Sandbox Code Playgroud)
等等。
顺便说一句,这适用于所有 Linux/Unix 系统。