I am building an App is VS Pro 2013 using .NET4.5 C#/ASP.NET. I am also using Bootstrap.min.js and JQuery 2.1.4.in.js.
I have created a folder structure for a certain set of web pages. From the root directory it looks like this:
Root Dir/Folder/Folder/Folder/Default.aspx
I also have a navbar on the page which has drop downs. In the drop downs I have added my HREF's to other pages in and around my folder structure for the web pages.
I have two links in the drop down menu that reference web pages, as you would expect using HREF.
The code for the navbar is as folows:
<li class="dropdown" >
<a class="dropdown-toggle" data-toggle="dropdown" style="cursor:pointer">Sites
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="#">View Site Dashboard</a></li>
<li><a href="#">View Site Reports</a></li>
<li class="divider"></li>
<li><a href="#">Set/Edit Site Targets</a></li>
<li class="divider"></li>
<li><a href="~/EMS/Sites/EditSite/Default.aspx">Edit Site Details</a></li>
<li><a href="~/EMS/Sites/Addsite/Default.aspx">Add Another Site</a></li>
</ul>
</li>
There are only two active links, I took the others out as they were also doing the same thing.
When I run the application, what I see when I hover over the link on the drop down is localhost:port#/EMS/Sites/AddSite/~EMS/Sites/Addsite/Default.aspx when it should in fact be localhost:port#/EMS/Sites/AddSite/Default.aspx
Its as if it has taken the present location of the aspx file and then added the HREF link to the end of it. As this location doesn't exist, it 404's.
I have tried changing the path from relative to absolute and mixing up things, but it is not a happy bunny.
I have also tried in web.config and routeconfig.cs...
Any ideas anyone, I have never come across this before!
Any link that starts with anything other than a protocol (e.g., http://
) or a /
is going to be seen as a relative link, i.e., relative to the current page. If you want your links to be relative to the site root, use /~/...
.
That said, based on your description of what you're trying to do, I'm not sure why you used ~
at all; that should probably be #
.