Get friendly Url in EPiServer

Sometimes you might run into a problem where EPiServer doesn't convert page.LinkURL to a friendly Url. Instead you get an Url to your template with Querystring parameters such as PageId and Language. However there's a way to ensure that you get the friendly Urls instead:
EPiServer.UrlBuilder url = new EPiServer.UrlBuilder(page.LinkURL);
EPiServer.Global.UrlRewriteProvider.ConvertToExternal(url, page.PageLink, System.Text.UTF8Encoding.UTF8);
You then use url.ToString() to get a proper Url.

Related posts:

Comments

comments powered by Disqus