Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
AI OnAI Off
Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
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.