草庐IT

mongodb - Sitecore 8.1 错误 : "No session Id managers were found to manage the session Id for the current request"

coder 2023-10-27 原文

我试图在 Sitecore 8.1 中启动并运行基本布局,但我遇到了一个错误,关于该错误我只能找到很少的信息。尝试查看任何页面(即使是后端界面或从 Sitecore Rocks 连接)时,我收到消息“找不到 session ID 管理器来管理当前请求的 session ID。”

一些谷歌搜索表明这与开箱即用的 session 提供程序的一些问题有关,并建议将其换掉以将 session 保留在 Mongo 中。 Sitecore 的文档提供了这方面的描述,均适用于 shared。和 private session 。我已尝试实现这些,但仍然收到相同的错误。

这是我现在的代码:

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 在其中创建了 session 和 sharedsession 数据库,据我所知在 Mongo 中创建数据库的方法。

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

最佳答案

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

为什么通常会出现这个警告

Sitecore.config<pipelines>getSessionIdManager管道定义。

<getSessionIdManager>
</getSessionIdManager>

Sitecore.FXM.config 中,有一个为此管道配置的处理器:

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

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

对于所有其他请求,不会显式选择 session ID 管理器,并且默认 System.Web.SessionState.SessionIDManager将会被使用;这反射(reflect)在您看到的警告消息中。这种情况本身并没有什么问题,这是默认情况下的设计。

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

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

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

尝试修复

我不能调试你的系统,所以我必须蒙着眼睛来做这件事。我会尝试创建您自己的 session ID 管理器选择器:

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

将其配置为 getSessionIdManager 中的最后一个 处理器管道。这将确保始终有一个明确选择的 session ID 管理器,并有望防止错误发生。

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

关于mongodb - Sitecore 8.1 错误 : "No session Id managers were found to manage the session Id for the current request",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34204809/

有关mongodb - Sitecore 8.1 错误 : "No session Id managers were found to manage the session Id for the current request"的更多相关文章

随机推荐