webapi中默认是不支持session的开启的需要在Global.asax文件中,添加如下代码public override void Init() { this.PostAuthenticateRequest += (sender, e) => HttpContext.Current.SetSessionStateBehavior( System.Web.SessionState.SessionStateBehavior.Required); base.Init(); }