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!

Redirect to a URL set by a URL property field.


I have a custom block, with a URL field.  (EpiServer.Url) 

In the editor, I go to the properties and set the page from other pages in the site.  In this case, "Contact Us".  (site path, "/en/contact-us")

But when the controller gets the path, it looks like this: "/link/03b82dc1edc34762bfa4575c24180166.aspx?id=373&epslanguage=en", not "/en/contact-us".

What do I do to get the real path.

May 13, 2015 23:05
May 14, 2015 0:03

This should work

var urlHelper = ServiceLocator.Current.GetInstance<UrlResolver>();
var friendlyUrlBuilder = new UrlBuilder(<!----Your url string here -->);
ContentReference contentReference = PermanentLinkUtility.GetContentReference(friendlyUrlBuilder);
 string url = urlHelper.GetUrl(contentReference);
return url;
May 14, 2015 10:42

var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();
var pageUrl = urlResolver.GetUrl(contentReference, cultureName);

In a cshtml view
<a href="@Url.ContentUrl(EPiServer.Url)">

Edited, May 14, 2015 11:57

You can get real path using UrlHelper

var urlHelper = ServiceLocator.Current.GetInstance<UrlHelper>();
var url = urlHelper.ContentUrl(currentBlock.Link);
May 14, 2015 12:16
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.