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

Try our conversational search powered by Generative AI!

Check if page is in Edit vs Preview vs View modes

Vote:
 

I know how to check if a page is in Edit (in the CMS ready for editing) mode. However, can Preview mode be distinguished between Preview inside the CMS framework and what the end user sees?

#152062
Aug 15, 2016 14:53
Vote:
 

Tried EPiServer.Web.Routing.Segments.RequestSegmentContext.CurrentContextMode?

That should give you an enum with either Default / Edit / Preview...

#152064
Edited, Aug 15, 2016 15:13
Vote:
 

Fantastic, that worked! Thanks so much.

#152067
Aug 15, 2016 16:09
Vote:
 

Normally you just need to use PageEditing.PageIsInEditMode to check for edit mode, I guess you've found that one already, but if you need the preview mode as well then you need to use the RequestSegmentContext.CurrentContextMode to get it. 

PageEditing.PageIsInEditMode uses this class under the hood btw :)

#152073
Aug 15, 2016 17:03
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.