ASP.MVC Session为null

ASP.NET MVC应用本地开发测试正常,然而,发布到测试服务器上没法正常登录,日志跟踪发现Session为null

快速解决办法

<configuration>
  ...
  <system.webServer>
    ...
    <modules>
      <remove name="Session" />
      <add name="Session" type="System.Web.SessionState.SessionStateModule"/>
      ...
    </modules>
  </system.webServer>
</configuration>

参考:https://stackoverflow.com/questions/218057/httpcontext-current-session-is-null-when-routing-requests

posted @ 2019-08-15 17:11  Mr宋  阅读(619)  评论(0编辑  收藏  举报
TOP