Click here to Skip to main content
15,169,285 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
this is my code
<li role="presentation "><a href="~/index.aspx">Home</a></li>

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
Posted
Updated 2-Jun-15 20:43pm
v2

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


refer :use of tilde (~) in asp.net path[^] for more information
   
v2
try this....

HTML
<ul><li role="presentation "><a href="index.aspx">Home</a></li></ul>
   
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>


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

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


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.
   
where this page is located, if it is in any folder then use the below code
use "../Account/index.aspx" in href
   
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900