码迷,mamicode.com
首页 > Windows程序 > 详细

.net webapi项目中支持session

时间:2016-05-25 16:55:56      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:

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

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

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

 

.net webapi项目中支持session

标签:

原文地址:http://www.cnblogs.com/sjns/p/5527404.html

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