【问题标题】:How can I make the MySqlSessionStateProvider use cookies in my .NET MVC app?如何让 MySqlSessionStateProvider 在我的 .NET MVC 应用程序中使用 cookie?
【发布时间】:2013-05-01 20:22:06
【问题描述】:

我的 web.config 中有以下内容:

<system.web>
<sessionState mode="Custom" regenerateExpiredSessionId="true" customProvider="MySqlSessionStateProvider">
  <providers>
    <add name="MySqlSessionStateProvider" type="MySql.Web.SessionState.MySqlSessionStateStore, MySql.Web, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" applicationName="App_Name" description="App_Description" connectionStringName="MySqlSession" writeExceptionsToEventLog="True" autogenerateschema="True" enableExpireCallback="True" />
  </providers>
</sessionState>

我在 web.config 的 ConnectionStrings 部分中定义了 MySqlSession 连接字符串。

当我运行该站点时,数据库中的会话表没有被填充。但是,如果我将 cookieless=true 添加到 customProvider 中,会话表会被填充,但会话字符串会显示在 URL 中。我不想在 URL 中显示会话字符串,因为这会干扰我的负载均衡器。如何让 MySqlSessionStateStore 使用 cookie?

【问题讨论】:

    标签: mysql asp.net-mvc session-cookies session-state


    【解决方案1】:

    我错误地识别了问题。我只需要将身份验证保留在我的负载均衡器中。我通过确保每个 IIS 实例上的机器密钥相同来解决这个问题。

    上面列出的 sessionState 已完全删除,因为我没有在会话中存储任何自定义内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-01-12
      • 2015-01-06
      • 1970-01-01
      • 2012-01-10
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      相关资源
      最近更新 更多