Sitecore 8.1 error: "No session Id managers were found to manage the session Id for the current request"

Sitecore 8.1 error: "No session Id managers were found to manage the session Id for the current request"

我试图在 Sitecore 8.1 中建立基本布局和 运行,但我遇到了一个错误,关于该错误我找不到多少信息。尝试查看任何页面(甚至后端界面或从 Sitecore Rocks 连接)时,我收到消息 "No session Id managers were found to manage the session Id for the current request."

一些谷歌搜索表明这与开箱即用的会话提供程序的一些问题有关,并建议将其换掉以将会话保留在 Mongo 中。 Sitecore 的文档针对 shared and private 会话提供了对此的描述。我已经尝试实施这些但仍然收到相同的错误。

这是我现在的代码:

App_Config/Include/MongoSessionProvider.config

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <tracking>
      <sharedSessionState>
        <providers>
          <clear/>
          <add name="mongo" type="Sitecore.SessionProvider.MongoDB.MongoSessionProvider, Sitecore.SessionProvider.MongoDB" connectionString="session" pollingInterval="2" compression="true" sessionType="shared"/>
        </providers>
      </sharedSessionState>
    </tracking>
  </sitecore>
</configuration>

App_Config/Include/ConnectionStrings.config(摘录)

<add name="session" connectionString="mongodb://localhost/sharedsession" />

Web.config(节选)

<sessionState mode="Custom" cookieless="false" timeout="20" sessionIDManagerType="Sitecore.FXM.SessionManagement.ConditionalSessionIdManager" customProvider="mongo">
  <providers>
    <add name="mongo" type="Sitecore.SessionProvider.MongoDB.MongoSessionStateProvider, Sitecore.SessionProvider.MongoDB" sessionType="Standard" connectionStringName="session" pollingInterval="2" compression="true" />
    <add name="mssql" type="Sitecore.SessionProvider.Sql.SqlSessionStateProvider, Sitecore.SessionProvider.Sql" sessionType="Standard" connectionStringName="session" pollingInterval="2" compression="true" />
  </providers>
</sessionState>

请注意,这是在我的本地开发机器上。我有 Mongo 运行(并确认它与 Sitecore 的连接),我使用 use sessionuse sharedsession 在其中创建了会话和共享会话数据库,据我所知在 Mongo.

中创建数据库的方法

我是不是漏掉了什么?或者错误根本不是我认为的意思?

您看到的消息不应是错误,而是日志警告。它与检索会话 ID 管理器的配置有关,而不是与会话本身的配置有关。

为什么通常会出现此警告

Sitecore.config 下的 <pipelines> 中定义了 getSessionIdManager 管道。

<getSessionIdManager>
</getSessionIdManager>

Sitecore.FXM.config中,有一个为此流水线配置的处理器:

<getSessionIdManager>
  <processor type="Sitecore.FXM.Pipelines.ChooseSessionIdManager.FXMSessionIdManagerProcessor, Sitecore.FXM" />
</getSessionIdManager>

此管道允许为请求动态 select 会话 ID 管理器。在默认的 Sitecore 配置中,非默认会话 ID 管理器将仅用于具有显式 sessionId URL 参数的请求,即仅用于 FXM 请求。

对于所有其他请求,不会显式 select 编辑任何会话 ID 管理器,并且将使用默认值 System.Web.SessionState.SessionIDManager;这反映在您看到的警告消息中。这种情况本身没有任何问题,这是默认情况和设计。

在每次页面请求时将消息视为错误

这对我来说绝对是一个缺陷。此消息应该在每个应用程序生命周期 记录 一次,而不是在每个页面上作为异常抛出。

您应该将此报告给 Sitecore 支持。

尝试修复

我无法调试你的系统,所以我不得不蒙着眼睛来做这件事。我会尝试创建您自己的会话 ID 管理器 select 或:

public class CustomSessionIdManagerProcessor
{
    public void Process(GetSessionIdManagerArgs args)
    {
        if(args.SessionIdManager == null)
        {
            args.SessionIdManager = new System.Web.SessionState.SessionIDManager();
        }
    }
}

将其配置为 getSessionIdManager 管道中的 最后一个 处理器。这将确保始终有一个明确的 selected 会话 ID 管理器,并且应该有望防止错误发生。

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <getSessionIdManager>
        <processor type="YourNamespace.CustomSessionIdManagerProcessor, YourAssembly" />
      </getSessionIdManager>
    </pipelines>
  </sitecore>
</configuration>

如果它对其他人有帮助,我们 运行 在升级到 Sitecore 8.1 版本后也陷入了这个问题。 151003.

在我们的特定情况下,问题出在 Web.config:

这一行中的命名空间更改
<sessionState mode="InProc" cookieless="false" timeout="20"
 sessionIDManagerType="Sitecore.FXM.SessionManagement.ConditionalSessionIdManager">

应该是这样的:

<sessionState mode="InProc" cookieless="false" timeout="20"
 sessionIDManagerType="Sitecore.SessionManagement.ConditionalSessionIdManager">

它可能是我们在升级指南中遗漏的东西,但我们最终在下载 Sitecore 8.1 版本的副本后找到了它。 151003.zip 来自 the downloads page.