开发者

Absolute and relative paths in an Asp.NET project

When using a like so:

<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 p开发者_如何学编程roject 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?


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.


It goes back one directory.

/one/two/three/etc Assumes that /one is in the root directory. Hope it helps


../One/Two/Three/Four.aspx goes back one directory

/One/Two/Three/Four.aspx starts from the root

Read this article which explains everything including the use of tilde (~)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜