开发者

Sitecore API check in code behind if page is being previewed

开发者 https://www.devze.com 2023-03-07 03:54 出处:网络
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 happen

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");
        }
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消