Try our conversational search powered by Generative AI!

Resolve property EPiServer.Url?



I'm probably getting rusty (...or I'm just in need of a X-Mas holiday break...) since I'm asking this question but here goes.

If I have a property on a block type that is of type EPiServer.Url, how do I resolve it? Or parse it to a friendly URL?

UrlResolver can take care of EPiServer.Core.ContentReference but I've forgotten if there's anything similar for EPiServer.Url.

We're running EPiServer CMS

Dec 12, 2018 11:27

We use the following method for this scenario:

public static string FriendlyUrlFromUrl(string linkUrl)
    var url = new UrlBuilder(linkUrl);
    Global.UrlRewriteProvider.ConvertToExternal(url, null, Encoding.UTF8);

    return url.Uri.IsAbsoluteUri ? url.Uri.AbsoluteUri : url.Uri.OriginalString;
Dec 12, 2018 13:32

I usually use the System.Web.Mvc.UrlHelper.ContentUrl which takes a Url property and returns the correct url going through the UrlResolver internally. It's part of Episerver's EPiServer.Web.Mvc.Html namespace

Dec 12, 2018 13:50
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.