Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

[Bug?] EPiEditMode in RequestContextEventArgs of CreatingVirtualPath is always set to false

Vote:
 

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.

#69127
Mar 22, 2013 11:04
Vote:
 

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.

#69128
Mar 22, 2013 11:13
Vote:
 

I have though added a bug that the EPiEditMode property Submiton the eventargs should be initialized according to current state.

#69137
Mar 22, 2013 12:42
Vote:
 

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.

#147400
Apr 13, 2016 15:26
Vote:
 

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

#147423
Apr 14, 2016 9:22
Vote:
 

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

#147425
Apr 14, 2016 9:31
Vote:
 

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?

#147426
Apr 14, 2016 9:34
Vote:
 

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) { 

 

#147427
Apr 14, 2016 9:41
Vote:
 

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.

#147430
Apr 14, 2016 10: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.