URLs - relative and the use of ~

Posted on 2012-09-19
Last Modified: 2012-09-25
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?
Question by:Lorna70
    LVL 18

    Accepted Solution

    LVL 25

    Assisted Solution

    This sounds like you are hosting on your dev machine via Visual Studio's ASP.NET server, instead of IIS.   You should use IIS ALWAYS!


    Set up using IIS

    Author Comment

    Yes this is only on my development machine so I thought that maybe when hosted using IIS the problem would disappear.  I'm setting up a new pc with Windows 7 so I can have IIS on my development machine (currently Vista :-().

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now