.net webapi项目中支持session

webapi中默认是不支持session的开启的

需要在Global.asax文件中,添加如下代码

public override void Init()
        {
            this.PostAuthenticateRequest += (sender, e) => HttpContext.Current.SetSessionStateBehavior(
                System.Web.SessionState.SessionStateBehavior.Required);
            base.Init();
        }

 

posted on 2016-05-25 16:08  sjns  阅读(364)  评论(0编辑  收藏  举报

导航