November Happy Hour will be moved to Thursday December 5th.

Detecting if a page/server is int the 'Edit mode'

Vote:
 

 

 Hello, everyone!

 I need some advice regarding the 'Edit' mode of the EPiServer CMS (v.5). Is there any possibility to exactly detect from the code behind that currently a page is viewed in the 'Edit' mode?

#26801
Dec 22, 2008 14:26
Vote:
 

Hi Andrey.

I think this still works:

public static bool IsEditOrPreviewMode

{

get

{

HttpRequest request = HttpContext.Current.Request;

Uri referrer = request.UrlReferrer;

return referrer != null && referrer.Host == request.Url.Host && referrer.Segments[referrer.Segments.Length - 1].Equals( "EditPanel.aspx", StringComparison.InvariantCultureIgnoreCase );

}

}

#26807
Dec 22, 2008 16:00
Vote:
 
Thank you, Fredrik, it's working!
#26813
Dec 23, 2008 8:21
* 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.