Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如果正在预览页面,则Sitecore API签入代码隐藏_C#_Asp.net_Sitecore - Fatal编程技术网

C# 如果正在预览页面,则Sitecore API签入代码隐藏

C# 如果正在预览页面,则Sitecore API签入代码隐藏,c#,asp.net,sitecore,C#,Asp.net,Sitecore,我的Sitecore站点中有一个子布局,用于通过元刷新(临时措施)执行重定向,但是我希望编辑器能够在不发生重定向的情况下预览页面。页面加载方法中是否有方法使用Sitecore API检查页面是否正在预览?是,检查页面模式。假设可以将元刷新移动到重定向,则可以执行以下操作: protected void Page_Load(object sender, EventArgs e) { if(!Sitecore.Context.PageMode.IsPreview)

我的Sitecore站点中有一个子布局,用于通过元刷新(临时措施)执行重定向,但是我希望编辑器能够在不发生重定向的情况下预览页面。页面加载方法中是否有方法使用Sitecore API检查页面是否正在预览?

是,检查页面模式。假设可以将元刷新移动到重定向,则可以执行以下操作:

    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Sitecore.Context.PageMode.IsPreview)
        {
            // Not in preview mode
            Response.Redirect("redirectionurl.aspx");
        }
    }