HttpContext.Current.Session[strName]未将对象引用设置到对象的实例

项目开发是在4.5.1上,不知道为啥客户提供的服务器上安装的是4.5,差别不大也没去升级,然后部署MVC的时候web.config报错

<system.web>
    <compilation debug="true" targetFramework="4.5.1"/>
    <httpRuntime targetFramework="4.5.1"/>
  </system.web>

然后也没在意就把这段给删掉了,然后Session那块就开始报错

HttpContext.Current.Session[Key.SessionOpenID] = openID;未将对象引用设置到对象的实例,因为用到了异步,所以一直报错,
最后在StackOverflow找到了原因

 

https://stackoverflow.com/questions/18383923/why-is-httpcontext-current-null-after-await 

实在是蛋疼啊

警告:如果你的项目升级到4.5.一定要记得在webconfig里面加上这句话。

posted @ 2017-06-01 22:22  小破天  阅读(1758)  评论(0编辑  收藏  举报