How to get the correct link from `LinkItem.Href` in Episerver?

  • Page Owner: Not Set
  • Last Reviewed: 2019-05-17

How can i get the actual link from EPiServer.SpecializedProperties.LinkItem.Href? The returned url looks something like this:

~/link/ca38f5e6e7a644e596a605e9e7e3d871.aspx

but I want an actual nice url (slug).


Additional Posts

So you use the UrlResolver or Url.ContentUrl for Razor Views. You can use Url.ContentUrl(EPiServer.SpecializedProperties.LinkItem) in Views or you can use the urlResolver in conjunction with Urlbuilder.

EPiServer.Web.Routing.UrlResolver.Current.GetUrl(new EPiServer.UrlBuilder(LinkItem.Href));

Comments

  • EPiServer.Web.Routing.UrlResolver.Current.GetUrl(new EPiServer.UrlBuilder(LinkItem.Href)); did not work, but Url.ContentUrl did.
  • @TylerHarms code behind is the full url builder