码迷,mamicode.com
首页 > Web开发 > 详细

【MVC2】发布到IIS7.5上后Session为null

时间:2015-09-09 19:19:31      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:

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

 

【MVC2】发布到IIS7.5上后Session为null

标签:

原文地址:http://www.cnblogs.com/Ryukaka/p/4795283.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!