Error in in creting links after upgrading

 

Hi.

We find that after upgrading to EPiServer 7 some of the links to other internal pages are rendered incorrectly.
If the page linked to have several language versions (English and Norwegian) the English name is used in the link although the link is on a Norwegian page.

Is there anyone who has experienced something similar?

#64591 Jan 03, 2013 15:13
  •  

    It looks like this have something to do with the UrlRewriteModule. If I disables the UrlRewriteModule I see that the link is correct, contains the correct language code in the esplanguage parameter.

    Someone have any idees on how to fix this problem?

    #65498 Jan 31, 2013 7:11
  • Timea Eriksson
    Member since: 2005
     

    We've had the same problem and reported this, but I've haven't found a solution so far. We can't use the CurrentPage.LinkUrl at all, most of the time the link is in english and not swedish although we have set swedish as main language and the page is in swedish, and other times the link is in mixed languages. In our case, the url is in english even if we have a property of type pagereference, were we specifically select a swedish page, and state that the page should be gotten in the swedish language. We have gotten around this problem by always using the urlresolver to get the link in the correct language. Although, it would be nice to simply be able to use the linkurl. I hope someone finds the problem soon.

    var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();
    var url = urlResolver.GetVirtualPath(contentLink, languageBranch);

    #65509 Edited, Jan 31, 2013 9:39
  •  

    Hi.

    I was able to solve this problem by creating a custom UrlRewriter, CustomHierarchicalUrlRewriteProvider that extends HierarchicalUrlRewriteProvider. In the HierarchicalUrlRewriteProvider there is a method ConvertToExternalInternal, it contains amongst other thing thes two lins of code:

    if (UrlRewriteContext.Languages.Count == 1 || LanguageSelection.IsHostLanguageMatch(currentLanguageBranch))

        currentLanguageBranch = string.Empty;

    After experiencing with the method explained by Timea Eriksson i found out that clearing the currentLanguageBranch caused the url to be generated with the wrong pagenames.

    So i made a override of the method in my UrlRewiter replicating the behaviour of the original function except thos two lines, therby fixing the problem.

     

    Does anyone know the concequences of removing those two lines?

     

    #65566 Feb 01, 2013 11:14
  • Linus Ekström
    Member since: 2002
     

    Thanks for the report. We will have a look to see if we can fix this.

    #65577 Feb 01, 2013 13:44