Try our conversational search powered by Generative AI!

Resolve property EPiServer.Url?

Vote:
 

Hi!

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 10.10.4.0.

#199814
Dec 12, 2018 11:27
Vote:
 

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;
}
#199817
Dec 12, 2018 13:32
Vote:
 

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

#199819
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.