Href 链接到子文件夹 [英] Href links to subfolders

查看:55
本文介绍了Href 链接到子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了一下,觉得这是一个基本问题,但我想我想不通.

I searched and feel this is an elementary questions but I can't think straight I guess.

所以我在我的网站和页面中有一个简单的子文件夹,我需要喜欢这个.

So I have a simple subfolder in my website and pages I need to get to like this.

<a href="Default.aspx">Home</a>

<a href="Subfolder/help.aspx">Help</a>

所以当我打开我的应用程序时,我会转到默认页面,在那里我可以单击帮助"页面,该页面会将我带到子文件夹中的页面,现在,如果我单击主页"链接,它会尝试将我带到/子文件夹/home.aspx?

So when I open my application, I go to the default page where I can click the Help page which takes me to the page in the subfolder, now, if I click on the Home link, it tries to take me to /subfolder/home.aspx ?

我明白正在做什么,但我不知道我可以让相对路径按照我想要的方式工作.我可以使用绝对路径,但我不应该.

I understand what is doing but I don't know I can make the relative path work the way I want it. I can use absolute path but I should not.

请问有什么帮助吗?

推荐答案

试试这个:

<a href="~/Default.aspx" runat="server">Home</a>

<a href="~/Subfolder/help.aspx" runat="server">Help</a>

现在,每个链接都将在服务器端解析,从项目根目录向下.

Now, each link will resolve on the server-side, from the project root downwards.

这篇关于Href 链接到子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆