无法找到该资源。 asp.net网络表单 [英] The resource cannot be found. asp.net web forms

查看:77
本文介绍了无法找到该资源。 asp.net网络表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码

<li role="presentation "><a href="~/index.aspx">Home</a></li>



当运行iam点击index.aspx资源找不到错误确实来了

plz帮帮我先生

error url看起来像(褐色网址):



http://localhost/onlineexamsworld/Account/~/index.aspx----->错误网址

plz help sir


when run iam clicking index.aspx the resource can't found error did come
plz help me sir
error url look like(browers url) :

http://localhost/onlineexamsworld/Account/~/index.aspx----->error url
plz help sir

推荐答案

使用服务器控件,包括 runat =server它会起作用

~ work with server controls, include runat="server" and it will work
<li role="presentation "><a href="~/index.aspx" runat="server">Home</a></li>





参考:在asp.net路径中使用波浪号(〜) [ ^ ]获取更多信息


try这....



try this....

<ul><li role="presentation "><a href="index.aspx">Home</a></li></ul>


〜表示法不是http标准的一部分,你的浏览器没有给它任何特殊的意义,它是一种指示网站根目录的.net方式。因此,只有.net控件才能解释〜并用正确的路径替换它。所以这将起作用



The "~" notation is not part of the http standards, your browser doesn't give it any special significance, it is a .net way of indicating the root of the site. So only .net controls have the ability to interpret the "~" and replace it with the correct path. So this will work

<asp:HyperLink runat="server" NavigateUrl="~/index.aspx">Home</asp:HyperLink>





如果你不想使用.net控件,你可以这样做





If you don't want to use a .net control you can do this instead

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





浏览器知道/表示站点根目录,但是如果您将站点放在虚拟目录中,则/将不再起作用,但.net版本将会,这就是为什么它最好使用.net控件。



作为附注,如果你甚至无法获得工作链接那么我强烈建议你阅读书籍在你尝试更复杂的东西之前,基本的html和asp.net。论坛有助于提出具体问题,但不能从头开始学习。来到这里询问你遇到的每一个问题都是不合理的。



The browser knows that "/" means site root, however if you put your site in a virtual directory then the "/" will not work any more, however the .net version will, that is why it is best to use the .net controls.

As a side note, if you can't even get a link to work then I strongly suggest you go through books on basic html and asp.net before you try anything more complex. Forums are good for asking specific questions, but not learning something from scratch. It is going to be unreasonable to come here and ask about every single problem you have.


这篇关于无法找到该资源。 asp.net网络表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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