C# Session 未对对象引用到实例

来源:互联网 发布:商城购物车数据库设计 编辑:程序博客网 时间:2024/06/05 15:29

问题描述:

在filter 中对session 进行赋值时报的错误“”未对对象引用到实例“”


解决方案:

在Global.asax 中加入以下代码即可

  public override void Init()        {            PostAuthenticateRequest += MvcApplication_PostAuthenticateRequest;            base.Init();        }        void MvcApplication_PostAuthenticateRequest(object sender, EventArgs e)        {            HttpContext.Current.SetSessionStateBehavior(SessionStateBehavior.Required);        }


阅读全文
0 0
原创粉丝点击