首页 > Windows开发 > 详细

.net webapi项目中支持session

时间:2016-05-25 16:54:34      阅读:248      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!