Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

How go get friendly URL for a PageData object?

Hi, I've noticed that the PageData.LinkURL property always returns the ordinary URL to the page, even though friendly URL is activated. What's the easiest way to get the friendly URL for a specific PageData-object? Thanks, Christoffer
Sep 12, 2007 13:35
In most cases there should be no need for you to bother with the friendly URL representation. The design goal is that the developer should only have to deal with "classic" urls (for example /templates/page.aspx?id=23). In some cases, when content in EPiServer should be exposed externally without being transmitted as a HTML response you may want to get the friendly URL representation. The typical use-case is sending EPiServer data via e-mail. This is supported with the ConvertToExternal method on UrlRewriteProvider. A short example on how to perform this: UrlBuilder url = new UrlBuilder(page.LinkURL); EPiServer.Global.UrlRewriteProvider.ConvertToExternal(url, page.PageLink, System.Text.UTF8Encoding.UTF8); // url now contains the rewritten URL Note that the second parameter (page.PageLink) is not necessary, passing null will deduce the PageReference from the url, but if it is known you will gain some perf by passing it. You should also take a look at the GetHtmlRewriter method on UrlRewriteProvider. This will rewrite an entire HTML chunk with friendly url conversion and rebasing, which may be closer to what you need. Best Regards, Magnus Stråle
Sep 13, 2007 10:32
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.