Try our conversational search powered by Generative AI!

PageData.PageLink is not returning correct language version URL

Vote:
 

Hi,
I'm continuing my struggle with EPiServer multi language support starting form here:
http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=51423&epslanguage=en

Now I have a problem from getting correct page URL for a language version in a custom generic handler.

Lets say this is my Generic Handler Code:
/Templates/Handlers/MyTestHandler.ashx

public void ProcessRequest(HttpContext context)
{
    ...
    PageReference testRef = new PageReference(38); //Some page with both english and german versions
    LanguageSelector langSelectorTest = new LanguageSelector("de"); //We want german version
    PageData test = EPiServer.DataFactory.Instance.GetPage(testRef, langSelectorTest);
    //test.LanguageBranch - is de - correct!
    //test.LanguageID - is de - correct!
    //test.PageName - is german version - correct!
    //test.PageLink - is "/SomePath/SomeName.aspx?id=38&epslanguage=en" - Not correct

    //Let's try GetPageLanguage version
    PageData testAgain = test.GetPageLanguage(langSelectorTest.LanguageBranch);
    //testAgain.PageLink - is "/SomePath/SomeName.aspx?id=38&epslanguage=en" - Not correct
    ...
}

public bool IsReusable
{
    get
    {
        return false;
    }
}

For some reason PageLink is returning URL for english version instead of german

#51463
Jun 09, 2011 11:24
Vote:
 
#51466
Jun 09, 2011 13:15
Vote:
 

Hi Anders,
it looks like the same problem. Meanwhile, a colleague of mine gave me this solution:

UrlBuilder url = new UrlBuilder(UriSupport.AddLanguageSelection(page.LinkURL, page.LanguageID));
return url.ToString();

#51472
Jun 09, 2011 14:36
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.