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

Forums / Bugs & Issues / Dynamic LInks not relative / port number stripping.

Dynamic LInks not relative / port number stripping.

12 posts, 1 answered
  1. Jodie
    Jodie avatar
    27 posts
    Registered:
    28 May 2009
    21 Sep 2009
    Link to this post
    Hi-ho,

    We've got a work-in-progress website using the Standard Edition demo of Sitefinity.

    We were running 3.6 and our developer just upgraded to 3.7SP1.

    Now we have a problem with deynamic links rendering as absolute links and stripping the port number on them....

    I'm not sure if the system was rendering them absolute before or not, but the imediate problem is that while we're testing the site it's running on a non-standard port, and SF is stripping the :81 off the end of the dynamic links.

    Ideally I'd prefer links relative to the root to be rendered, as I'm sure it was doing before, but if not relative, keeping the URI intact with port number would be OK...

    Cheers, Chris H.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    21 Sep 2009
    Link to this post
    Hello Chris,

    Thank you for using our services.

    To resolve the dynamic links we use Control.ResolveUrl Method where as a parameter we pass the relative url and the port is skipped. We do not include the AbsoluteUri because if you migrate the website to another domain the links will be broken.

    Let us know if there is anything else that we can do for you.

    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.
  3. Jodie
    Jodie avatar
    27 posts
    Registered:
    28 May 2009
    21 Sep 2009
    Link to this post
    Ummmm,

    I'm not sure that helped me at all.

    in V3.6 URL's in generic content were rendered as /product/blah.aspx  which worked fine for all the testing we're doing as some users are working internally from port 80 and others through a port-forwarded firewall.

    Now dynamic links render as http://www.domain.com/product/blah.aspx even though th server is responding as www.domain.com:81

    Is there some way to disable this behaviour?  We've got over 600 pages with what appear to be broken links, and having a minor version upgrade break the site does not bode well for the future.

    Cheers, Chris H.
  4. Jodie
    Jodie avatar
    27 posts
    Registered:
    28 May 2009
    22 Sep 2009
    Link to this post
    FYI, although I'm sure you know this...

    The news listing control still renders relative URL's, as do some of the other controls...  So it's not even consistently wrong, which is handy, as I'm working on moving our news archive.. :-).

    Cheers, Me.
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Sep 2009
    Link to this post
    Hi Chris,

    If you check the link I sent you, you will see that we do not  use the domain name in resolving the url. You can take a look at the attached image to see that the server port is not affected.
    "We do not include the AbsoluteUri because if you migrate the website to another domain the links will be broken."

    All the best,
    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.
  6. Jodie
    Jodie avatar
    27 posts
    Registered:
    28 May 2009
    22 Sep 2009
    Link to this post
    Hmmmm....

    I've just created a new blank page, and put one link in a generic content block.

    The URL for the page is: http://polly.x-tend-life.com:81/Jodie/test.aspx

    if you view-source on that page the 'test' link in the header area is rendered in html as:

    <href="http://polly.x-tend-life.com/info/TB.aspx">test </a> 

    I'd like to see that rendered as /info/TB.aspx

    It's clearly stripping the :81, but that wasn't a problem in SF3.6 as the URL was rendered relative, which seems like a far more robust solution.

    I need a work-around for this, so if there is a config change, or a patch I can apply it would be appreciated.

    Or should I downgrade to 3.6 again?
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 Sep 2009
    Link to this post
    Hello Chris,

    We found a bug in GenericContent control related to your problem. It seems that absolute path is resolved instead of the relative one.

    Below is a workaround that you could try.

     1. Create a new class under  App_Code folder, which inherits the default GenericContent:

    sing System;  
    using System.Web;  
    using System.Web.UI;  
    using Telerik.Cms.Engine;  
    using Telerik.Cms.Engine.WebControls;  
    using Telerik.Cms.Web;  
      
    namespace Sitefinity.Samples  
    {  
        [System.ComponentModel.ToolboxItem(typeof(CustomGenericContentToolboxItem))]  
        public class CustomGenericContent : GenericContent  
        {  
            protected override void Render(HtmlTextWriter writer)  
            {  
                if (this.ContentID != Guid.Empty)  
                {  
                    base.Render(writer);  
                }  
                else if (!String.IsNullOrEmpty(this.Content))  
                {  
                    string text = (string)this.Content;  
                    text = LinkParser.ResolveLinks(text, this.GetItemUrlNew, nullthis.DesignMode, false);  
                    writer.Write(text);  
                }  
            }  
      
            public override void RenderTextContent(HtmlTextWriter writer)  
            {  
                if (this.SharedContent.Status == ContentStatus.Published  
                    || this.SharedContent is StagedContent)  
                {  
                    string text = (string)this.SharedContent.Content;  
                    if (this.SharedContent is IDynamicLinkContainer  
                        && ((IDynamicLinkContainer)this.SharedContent).HasDynamicLinks)  
                        text = LinkParser.ResolveLinks(text, this.GetItemUrlNew, nullthis.DesignMode, false);  
                    writer.Write(text);  
                }  
            }  
      
            private string GetItemUrlNew(string provider, Guid id, bool resolveAsAbsoluteUrl)  
            {  
                if (ContentManager.Providers.ContainsKey(provider))  
                {  
                    IContent cnt = ContentManager.Providers[provider].GetContent(id);  
                    if (cnt != null)  
                        return VirtualPathUtility.ToAbsolute(cnt.UrlWithExtension, this.Context.Request.ApplicationPath);  
                }  
                else  
                {  
                    ICmsUrlContext urlContext = UrlHelper.GetUrl(id);  
                    if (urlContext != null)  
                    {  
                        SiteMapNode node = urlContext.GetSiteMapNode();  
                        if (node != null)  
                            return VirtualPathUtility.ToAbsolute(node.Url, this.Context.Request.ApplicationPath);  
                    }  
                }  
                return String.Concat("Item not found: [", provider, "]", id);  
            }  
        }  
      
        public class CustomGenericContentToolboxItem : Telerik.Web.ToolboxItem  
        {  
            public CustomGenericContentToolboxItem()  
                : base(typeof(CustomGenericContent))  
            {  
                base.DisplayName = "Generic Content";  
                base.Description = "";  
            }  
        }  
    }  

    2. Register the control in your web.config file

     <toolboxControls>  
        <clear />  
        <add name="Generic Content" section="Most popular" type="Sitefinity.Samples.CustomGenericContent, App_Code" />  

    3. Change all GenericContent controls in the site to use the new type. You can do this by editing the pages through the user interface, or run the following sql into the database:

    update sf_WebControlBase  
    set [Type] = 'Sitefinity.Samples.CustomGenericContent, App_Code'  
    where [Type] like 'Telerik.Cms.Engine.WebControls.GenericContent, Telerik.Cms.Engine%'  

    The bug will be fixed in the next official release. If you upgrade your project you could run the following SQL query to return back the original GenericContent control and use it instead the workaround.

    update sf_WebControlBase  
    set [Type] = 'Telerik.Cms.Engine.WebControls.GenericContent, Telerik.Cms.Engine'  
    where [Type] like 'Sitefinity.Samples.CustomGenericContent, App_Code%'  

    We have a custom internal build that we could also send if required. I hope this helps.

    Greetings,
    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.
  8. Jodie
    Jodie avatar
    59 posts
    Registered:
    09 Oct 2012
    25 Sep 2009
    Link to this post
    Hi Ivan,

    I'm working with Chris on this project, is it possible to get the intenal build posted/sent?

    Thanks

    Jodie
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Sep 2009
    Link to this post
    Hi Jodie,

    We will attach the build withing a week to this ticket. Meanwhile you could use the workaround.

    Regards,
    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.
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Sep 2009
    Link to this post
    Hi Jodie,

    Please find attached the internal build for Sitefinity 3.7 SP1 ( .NET Framework 3.5) -Standard and Community Edition.

    Regards,
    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.
    Answered
  11. Jodie
    Jodie avatar
    27 posts
    Registered:
    28 May 2009
    28 Sep 2009
    Link to this post
    Thanks for that Ivan, the links all look good now.

    Cheers, Chris H.
  12. Jodie
    Jodie avatar
    59 posts
    Registered:
    09 Oct 2012
    28 Sep 2009
    Link to this post
    Hi Ivan,

    As always thanks for the support :) Seems to be working like a charm.

    Thanks

    Jodie
Register for webinar
12 posts, 1 answered