1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Relative Links (~/Foo.aspx) Redirect Incorrectly

Relative Links (~/Foo.aspx) Redirect Incorrectly

5 posts, 0 answered
  1. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    05 May 2009
    Link to this post
    In my template I have a section for navigation at the top. I put in some generic content that looks like this:

    <div id="constants">
    <ul>
    <li><a href="~/Login.aspx"><strong>Log In</strong></a> <span>|</span> </li>
    <li><a href="~/Register.aspx">Register</a> <span>|</span> </li>
    <li><a href="~/About.aspx">About</a> <span>|</span> </li>
    <li><a href="~/Library.aspx">Library</a> <span>|</span> </li>
    <li><a href="~/Community.aspx">Community</a> <span>|</span> </li>
    <li><a href="~/Newsletters.aspx">Newsletters</a> <span>|</span> </li>
    <li><a href="~/Home.aspx">Home</a> <span>|</span> </li>
    </ul>
    </div>

    The problem is that when I click on these in the live site, the links are all broken...http://localhost/MyProject/~/Login.aspx shows up. Its not seeing the tilde correctly as a reference to root but instead is lumping it to the base address. What am I missing?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    05 May 2009
    Link to this post
    Hello Armysniper,

    Use the following declaration:

    <div id="constants"
    <ul> 
    <li><a href="../Login.aspx"><strong>Log In</strong></a<span>|</span> </li> 
    <li><a href="../Register.aspx">Register</a> <span>|</span> </li> 
    <li><a href="../About.aspx">About</a> <span>|</span> </li> 
    <li><a href="../Library.aspx">Library</a> <span>|</span> </li> 
    <li><a href="../Community.aspx">Community</a> <span>|</span> </li> 
    <li><a href="../Newsletters.aspx">Newsletters</a> <span>|</span> </li> 
    <li><a href="../Home.aspx">Home</a> <span>|</span> </li> 
    </ul> 
    </div> 

    I hope this helps.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    05 May 2009
    Link to this post
    Wont that break if I have navigated in the site to a location like http://localhost/MyProject/Library/Documents/March_2008/Default.aspx
    and then click those links?
  4. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    06 May 2009
    Link to this post
    Yea that does not work...what does work, putting runat="server" on each link so that it forces the server to resolve the URL. If you used the ../ methodology it would remove the name of my project and everything would be http://localhost/AboutUs.aspx instead of http://localhost/MyProject/AboutUs.aspx.
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    06 May 2009
    Link to this post
    Hello Armysniper,

    A directory called .. (two periods) in a relative URL indicates the parent directory, stripping off everything up to the previous slash in the the Base URI. Notations cannot be used to go up higher than the root directory.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
5 posts, 0 answered