Sitecore API check in code behind if page is being previewed
I have a sublayout in my Sitecore site which is used to perform a redirect via a meta-refresh (a temporary measure) however I'd like editors to be able to preview the page without the redirect happening. Is there a way in the Page_Load method to check, using the Sitecore API, if the page is being previewe开发者_开发知识库d?
Yes, check the page mode. Assuming you can move the meta-refresh to a redirect you can do this:
protected void Page_Load(object sender, EventArgs e)
{
if(!Sitecore.Context.PageMode.IsPreview)
{
// Not in preview mode
Response.Redirect("redirectionurl.aspx");
}
}
精彩评论