November Happy Hour will be moved to Thursday December 5th.

Question regardning urls in episerver

Vote:
 

Hello

I have a copule of pages that have short urls given on them (page.Property["PageExternalUrl"]) now I'm in a situation where I need to get the "long friendly external url" (normal freindly url you get when short url is empty) programmaticly. Is there a way to get this url from pagedata object in a "good performance way" when you have given short url of given page?

/M

#65169
Jan 22, 2013 15:56
Vote:
 

Hi M,
you could try this:

        public static string GetFriendlyUrl(PageData page)
        {
            UrlBuilder url = new UrlBuilder(page.LinkURL);
            url.QueryLanguage = page.LanguageBranch;
            EPiServer.Global.UrlRewriteProvider.ConvertToExternal(
               url,
               page.PageLink,
               UTF8Encoding.UTF8);
            return url.ToString();
        }

    

#65210
Jan 23, 2013 10:13
Vote:
 

Thansks, but I've tried that. If current page has short url given I get the short url not the "friendly-long-url".... maybe its because of  custom made urlprovider in my case... i'll have to look into that... thanks!

 

#65211
Jan 23, 2013 10:30
Vote:
 

Oh, I see. However, in a standard 6 R2 site, the "GetFriendlyUrl" method I posted should still return the friendly url, and not the simple address. So yeah, checking custom code would probably be a step in the right direction :-)

It's also possible to turn of simple addresses, byt setting enableSimpleAddress="false" in web.config.

#65213
Edited, Jan 23, 2013 11:17
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.