That is actually by design. The property is exposed to make it possible to force the link to be generated for edit mode, that is if you set e.EPiEditMode = true;
the link will be generated for editmode. To find out if current request is in edit mode you could check
EPiServer.Editor.PageEditing.PageIsInEditMode
In next release there will also be an extension method GetContextMode on RequestContext to get this information.
I just ran into the same problem and it seems as now EPiServer have made the property that Johan refers to as Deprecated instead of fixing it.
I couldn't find a good way in my ContentRoute.CreatedVirtualPath attached event to find out if the requests is coming from the edit mode. (except doing string compare with Current.Request.Path)
I know this thread is dead old, but if someone else was caught looking for the same.
Hi, Magnus,
Doesn't this work for you:
private void CreatingVirtualPath(object sender, RequestContextEventArgs e) { var contextMode = e.RequestContext.GetContextMode(); if (contextMode == ContextMode.Edit) { // } }
BR,
Marija
Nope, contextmode gives "Default" even when the request is coming from inside EPiServer. In my case I saw that the requests came from the EPiServer tree:
See example image
I am checking this in CreatedVirtualPath, if that helps you.
Have you tried checking in latest AlloyTech project, just to rule out it's any custom functionality that affects this?
What does PageEditing.PageIsInEditMode return?
I havn't checked alloy project so far, it's a good idea to compare honestly.
PageEditing.PageIsInEditMode also returns false
One difference might be that I hook to the ContentRoute.CreatedVirtualPath, here are the important parts:
ContentRoute.CreatedVirtualPath += UrlRewriter.ChangeVirtualPathToHttps; public static void ChangeVirtualPathToHttps(object sender, UrlBuilderEventArgs args) { if (args.RequestContext.GetContextMode() == ContextMode.Default) {
I also did a test in the alloy website (EPi 9), and it seems that the EPiServer tree menu, when clicking on an expanding "+" the context mode is not Edit-mode anymore, see attached image
Many of the requests are in fact in marked as to be in edit mode, so this seems to be related on how that tree-menu fetches its content.
In the event ContentRoute.CreatingVirtualPath, e.EPiEditMode (in edit mode or not) always returns false, where e is RequestContextEventArgs.
Is this by design or will this bug perhaps be fixed in the version to come?
The workaround is to check e.UrlBuilder.QueryCollection["epieditmode"] in ContentRoute.CreatedVirtualPath (where e is UrlBuilderEventArgs), but it would be cleaner to check this in CreatingVirtualPath.