MVC2代码「Session.IsNewSession」在VS中可以正常执行,发布到IIS7.5上之后Session为null导致出错。

if (Session.IsNewSession)
{
    ......
}

解决方法是在Web.config中追加如下设定:

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

 

参考:http://stackoverflow.com/questions/10629882/asp-net-mvc-session-is-null

 

相关文章:

  • 2022-12-23
  • 2022-03-10
  • 2021-11-27
  • 2021-09-06
  • 2022-12-23
  • 2021-10-01
  • 2022-12-23
猜你喜欢
  • 2021-07-17
  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案