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

Forums / Developing with Sitefinity / How do I get my relative URL's to work?

How do I get my relative URL's to work?

9 posts, 0 answered
  1. Andrew
    Andrew avatar
    29 posts
    Registered:
    24 Jun 2009
    27 Jul 2009
    Link to this post
    I'm running into some confusion on my Master Pages with URL's that are part of the design and thus coded into the masterpage.

    All images are in the images folder.

    Thus if I have:

    <img src="images/header.jpg">

    This will work correctly if the page is a main page.  However when I try and create the page as a sub-page

    Page 1
      -  Sub-Page 1

    Then all of my links break.

    If I try and use an absolute such as:

    <img src="/images/header.jpg">

    This works fine when deployed, but doesn't work on the development side, because development points to:

    http://localhost/SiteName/

    Which results in me having <img src="http://localhost/images/header.jpg"> when I need <img src="http://localhost/sitename/images/header.jpg">

    Can anyone help me understand how this is supposed to work?

    Thanks! 
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    27 Jul 2009
    Link to this post
    Hello Andrew,

    This is the expected behavior when you have such paths.

    Please try to use a server side resolved urls:
    <img src="~/root/dirs/image/myimg.jpg"
    runat="server"
    id="someid"
    alt
    ="asd" /> 

    You can also use the <asp:Image> tag for the same purpose. This way, the right URL will be resolved on the server side before the rendering of the control.

    Regards,
    Georgi
    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. Andrew
    Andrew avatar
    29 posts
    Registered:
    24 Jun 2009
    27 Jul 2009
    Link to this post
    Hey Georgi,

    I will try that again, didn't seem to work the first time.  Also your system doesn't seem to handle <asp:ImageMap any ideas on that one?

    Thanks!
  4. Andrew
    Andrew avatar
    29 posts
    Registered:
    24 Jun 2009
    27 Jul 2009
    Link to this post
    I've tried all of the following, and just get broken images

     

    <td runat="server" style="width: 41px; height: 5px; background-image: url('~/images/SideBarBackgroundLeft.jpg'); background-repeat: repeat-y;"></td>

     

     


    Anyway to make backgrounds work?

     

  5. Andrew
    Andrew avatar
    29 posts
    Registered:
    24 Jun 2009
    27 Jul 2009
    Link to this post
    I'm having yet another problem here.  When I insert an image, flash object, etc. using the Sitefinity Editor into a Generic content.  It registers the domain as "/sitename/images/image.jpg", then when I upload to the live site, all of these images are broken, because they need to be pointing at "/images/image.jpg"
  6. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    28 Jul 2009
    Link to this post
    Hi Andrew,

    Here is what I do.

    1. Create a new master page. 
    2. Add the following image inside:
    <img src="~/Images/b.JPG" runat="server" id="one" alt="b" width="400" height="300"/> 

    Where the b.JPG is stored in the Images directory - ~/YourProject/Images/".

    3. Create a new page, and set it to use this template. It shows the picture as expected. 
    4. I move the page to a page group, so it becomes a child page of another page. I browse the live web site - the picture shows just fine again. 
    5. I create a new page under a page group, and set this template. Everything is as expected again. Could you please confirm this as well?

    As for your second question with the static paths, yes this is the case. We have prepared a special tool you could use, when you face the problem on the public site - ReplaceTool.
    Best wishes,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  7. Zahid Ali
    Zahid Ali avatar
    47 posts
    Registered:
    16 Nov 2009
    07 Dec 2009
    Link to this post
    Hi Georgi,

    Looking at your reply, i'd been trying to resolve the relative path issue and can't get the tilda (~) to work in the master template.

    Please advice.

    thanks.

    PS. the code i'm following is:
    <img src="~/Images/b.JPG" runat="server" id="one" alt="b" width="400" height="300"/> 
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    07 Dec 2009
    Link to this post
    Hello Zahid Ali,

    When you try to enter the src property the intellisense  should show "PickUrl", so the correct link will be selected. So, if you have an image located under the root folder called Images the link looks like as shown below:

    <img src="~/Images/MyImage.jpg" runat="server" id="one" alt="b" width="400" height="300"/>

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. Zahid Ali
    Zahid Ali avatar
    47 posts
    Registered:
    16 Nov 2009
    07 Dec 2009
    Link to this post
    ah, I thought the Root path is '/<project>/Sitefiniy/ ' and had my Images folder under Sitefinity folder.

    thanks Ivan, that helped!

    Cheers!
Register for webinar
9 posts, 0 answered