URLs - relative and the use of ~
Posted on 2012-09-19
Hi I have a file (control) at the root of my website called topbar.ascx which holds all my navigation buttons. The problem is I have sub-folders which also include this control on their pages. Therefore, how do I reference a url from outside and inside a sub-folder? I was advised to use ~. So in my topbar.ascx I have <li><a href="~/blog/default.aspx">Blog</a></li> which you would think would be ok. However, when I view pages including my topbar.ascx inside a browser and rollover a link, my status bar shows:
Why on earth is websitename/blog/ getting added to the front of the url?? Is this an IIS issue? I'm hoping this will be resolved when I publish live but I will be hosting the site on a shared server so maybe I will have the same issue??
Please can someone advise?