简体   繁体   English

Asp.NET项目中的绝对路径和相对路径

[英]Absolute and relative paths in an Asp.NET project

When using a like so: 当使用a像这样:

<a href="../One/Two/Three/Four.aspx">Search</a>

Does the .. go back one directory from where it is clicked, or does it go to the root of the project structure? ..是从单击目录返回到一个目录还是回到项目结构的根目录?

edit: A better way to ask: I am referencing a .js file from my Master page, how do I keep the reference relative if I don't know the depth of child pages that will use the Master page? 编辑:更好的询问方式:我是从母版页引用.js文件,如果我不知道将使用母版页的子页的深度,如何保持引用相对?

It goes back one directory. 它返回一个目录。

/one/two/three/etc Assumes that /one is in the root directory. /one/two/three/etc假定/one在根目录中。 Hope it helps 希望能帮助到你

../One/Two/Three/Four.aspx goes back one directory ../One/Two/Three/Four.aspx一/二/三/ ../One/Two/Three/Four.aspx返回一个目录

/One/Two/Three/Four.aspx starts from the root /One/Two/Three/Four.aspx从根开始

Read this article which explains everything including the use of tilde ( ~ ) 阅读本文 ,其中解释了所有内容,包括波浪号( ~ )的使用

The .. folder means one level down from the current folder. ..文件夹意味着比当前文件夹低一级。

The browser can't go from the project root folder, because it doesn't know where that root folder is, or what the project is for that matter. 浏览器无法从项目的根文件夹进入,因为它不知道该根文件夹在哪里,也不知道该项目在做什么。 You can use / at the beginning of an URL to go to the site root, but that may be different from the project root. 您可以在URL的开头使用/转到站点根目录,但这可能与项目根目录不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM