Try our conversational search powered by Generative AI!

Can you get the "public" URL of a page when rendering in Edit Mode?

Vote:
 

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?

#80143
Jan 15, 2014 16:25
Vote:
 

Use UrlResolver and its GetUrl(ContentReference contentLink, string language, VirtualPathArguments virtualPathArguments) method. Set the ContextMode property for virtualPathArguments to Default.

#80146
Jan 15, 2014 17:03
Vote:
 

For instance:

urlResolver.Current.GetUrl(content.ContentLink, content.LanguageBranch(), new VirtualPathArguments() { ContextMode = ContextMode.Default});

#80147
Jan 15, 2014 17:05
Vote:
 

Is this possible in CMS 7 (not 7.5)?

#80154
Jan 15, 2014 18:15
Vote:
 

This method is available in 7.5 only. I'm actually not sure of if and how it can be done in EPiServer 7.

#80166
Jan 16, 2014 7:54
Vote:
 

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;
        }

    

#80167
Jan 16, 2014 7:55
Vote:
 

Henrik -- that works, but in Edit Mode it still returns the Edit Mode URL, not the "public" URL.  This is my core problem.

#80210
Jan 16, 2014 15:31
Vote:
 

Interesting, should take a look at that, then we have wrong addresses in edit mode as well

#80253
Jan 17, 2014 15:02
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.