Get friendly Url of a page in EPiServer

There are several ways of getting a Url for a page.  If you want to get a friendly Url from a view, then I would strongly recommend reading this post to see all the options available to you: Creating a friendly URL within your EPiServer 7 MVC View with Route Data.

If, however, you want a quick and easy way in code, then I would recommend using the following approach:

public string GetFriendlyUrl(string linkUrl)
var url = new EPiServer.UrlBuilder(linkUrl);
EPiServer.Global.UrlRewriteProvider.ConvertToExternal(url, page.PageLink, System.Text.UTF8Encoding.UTF8);
return url.ToString();

You can then call the method using:

var friendlyUrl = GetFriendlyUrl(pageData.LinkURL);

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

More Posts

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *