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.
Use UrlResolver and its GetUrl(ContentReference contentLink, string language, VirtualPathArguments virtualPathArguments) method. Set the ContextMode property for virtualPathArguments to Default.
For instance:
urlResolver.Current.GetUrl(content.ContentLink, content.LanguageBranch(), new VirtualPathArguments() { ContextMode = ContextMode.Default});
This method is available in 7.5 only. I'm actually not sure of if and how it can be done in EPiServer 7.
We are using this extension method in 7.1
public static string FriendlyLinkURL(this PageData pageData)
{
var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();
var url = urlResolver.GetVirtualPath(pageData.ContentLink);
return !string.IsNullOrWhiteSpace(url) ? url.ToLowerInvariant() : string.Empty;
}
Henrik -- that works, but in Edit Mode it still returns the Edit Mode URL, not the "public" URL. This is my core problem.
Interesting, should take a look at that, then we have wrong addresses in edit mode as well
Whenin Edit Mode, every attempt to get the URL for a page returns the Edit Mode URL. I get why (you want people to continue navigating in Edit Mode), but I have a need to get the "public" URL while in Edit Mode.
Possible?