London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
AI OnAI Off
London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
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;
var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();
var pageUrl = urlResolver.GetUrl(contentReference, cultureName);
In a cshtml view
try
<a href="@Url.ContentUrl(EPiServer.Url)">
or
@Html.UrlLink(EPiServer.LinkUrl)
You can get real path using UrlHelper
var urlHelper = ServiceLocator.Current.GetInstance<UrlHelper>(); var url = urlHelper.ContentUrl(currentBlock.Link);
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.