从 Kentico 12 升级到 13 后页面预览错误

Error on Page Preview after upgrade from Kentico 12 to 13

我们有带 MVC 站点的 Kentico CMS。

我最近将 Kentico 12 升级到 13,并开始在管理应用程序中执行页面预览时收到“找不到资源”错误。在将 Kentico 12 NuGet 包更新到 13 之前,我没有从 MVC 应用程序中卸载它们。卸载它们并重新安装 13 后,错误已更改为以下错误。应用 13.0.52 修补程序没有进行任何更改。

Try reloading the administration interface. The user was not found in the JWT token, nor in the current virtual context URL.

这是堆栈跟踪:

Server Error in '/' Application. Try reloading the administration interface. The user was not found in the JWT token, nor in the current virtual context URL. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: CMS.Helpers.InvalidVirtualContextException: Try reloading the administration interface. The user was not found in the JWT token, nor in the current virtual context URL.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidVirtualContextException: Try reloading the administration interface. The user was not found in the JWT token, nor in the current virtual context URL.]
Kentico.Content.Web.Mvc.VirtualContextPrincipalRetriever.GetPrincipal(String jwtToken) +417
Kentico.Content.Web.Mvc.VirtualContextPrincipalAssigner.SetVirtualContextPrincipal(IVirtualContextPrincipalRetriever virtualContextPrincipalRetriever) +229
CMS.Base.AbstractHandler.CallEventHandler(EventHandler1 h, TArgs e) +115 CMS.Base.AbstractHandler.Raise(String partName, List1 list, TArgs e, Boolean important) +1028
CMS.Base.SimpleHandler2.RaiseExecute(TArgs e) +145 CMS.Base.SimpleHandler2.StartEvent(TArgs e) +236
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +223 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +220 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +94

编辑

我的 MVC 站点在 web.config 中有一个与安全相关的条目,这是导致此问题的原因。

<add name="X-Frame-Options" value="deny" />

它是由于页面预览的 <iframe> 行为而添加的。我们一直使用“在新标签页中预览”。不确定删除它是否安全。

您的实时 MVC 站点 运行 是否正确地独立于管理站点?请确保您的 MVC 站点 运行 正确并且您可以登录它。

此外,如果发送了令牌,请检查从管理站点发送到 MVC 站点的 URL。

请看documentation。它描述了当您自己设置此 header 时会发生什么:"如果您在 MVC 站点的 web.config 文件中手动应用 X-Frame-Options header,则Xperience 管理中的预览模式和所有相关功能(例如页面构建器和表单构建器)显示空白页面而不是预览内容。

它还解释了需要做什么:“如果您自己设置 CSP headers,请确保始终将 Xperience 管理 parent 站点列入白名单,使用frame-ancestors 政策。否则预览模式和所有相关功能将不会显示内容。"