Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

How do I tell whether I am in UI or View mode from codebehind?


I have already read this thread: which suggests either using the "idkeep" querystring parameter.

I'm getting partial success with but when I publish a page with "Composer - Edit On Page" the idkeep querystring parameter is still on the URL.

Is there a recommended way to tell whether you are in an editing interface (Composer/Standard UI) aside from the one I'm trying above?

May 01, 2012 12:26


This is one way

public static bool IsEditOrPreviewMode
        HttpRequest request = HttpContext.Current.Request;

        Uri referrer = request.UrlReferrer;

        return referrer != null &&
                referrer.Host == request.Url.Host &&
                referrer.LocalPath.EndsWith("EditPanel.aspx", StringComparison.InvariantCultureIgnoreCase);


May 01, 2012 14:40

Thanks for the reply. This works for the regular editor but not "Composer - Edit on page".

Are there any more alternatives? Should I have posted this in the Composer section?

May 09, 2012 15:19

The Composer ExtensionHandler has a property called ViewMode that you can look at.

Eg: if (_extensionHandler.ViewMode == ExtensionGeneric.ViewMode.ExtensionEditOnPageMode || _extensionHandler.ViewMode == ExtensionGeneric.ViewMode.ExtensionEditMode)

May 09, 2012 19:57

If using composer why not use Dropit.Extension.Core.BaseContentFunction.IsEditMode

May 10, 2012 16:51

Hi Frederik, Thanks for your tip. How would I get the value of _extensionHandler on a masterpage? 


Minesh, Thanks for reply. I know this method works in a composer function, but only if it is registered. I'd ideally like to implement this on a masterpage without registering a composer function I have no plans to use.

May 11, 2012 13:02

I have it in a base class for my Composer page types:

public abstract class ComposerPageBase<T> : TemplatePageBase<T> where T : TypedPageData
	//Add a ExtensionPageHandler to enable Composer
	private Dropit.Extension.Core.ExtensionPageHandler _extensionHandler;

	public ComposerPageBase()
		_extensionHandler = new ExtensionPageHandler();

	protected override void OnInit(EventArgs e)
		// Add meta tag to set default content compatible mode in IE 8
		HtmlMeta httpEquiv = new HtmlMeta();
		httpEquiv.HttpEquiv = "X-UA-Compatible";
		httpEquiv.Content = "IE=EmulateIE7";

		//It's important that _extensionHandler initialized after base.OnInit.

		if (_extensionHandler.ViewMode == ExtensionGeneric.ViewMode.ExtensionEditOnPageMode || _extensionHandler.ViewMode == ExtensionGeneric.ViewMode.ExtensionEditMode)


May 11, 2012 13:18

ahh i see. that works great, thanks for the help. the amusing thing is that i'm using it to set the same meta tag you have in your code snippet above!

May 15, 2012 10:45
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.