首页 > 应用Owin登录授权

应用Owin登录授权

我使用identity配合owin来做登录系统。每次登录后,owinContext.Authentication.User.Identity.IsAuthenticated的结果都是false;我的登录代码如下:

var owinContext = HttpContext.GetOwinContext();
 IdentityDbContext context = new IdentityDbContext("DefaultConnection1");
 IUserStore<IdentityUser> us = new UserStore<IdentityUser>(context);
 var um = new UserManager<IdentityUser>(us);


 SignInManager<IdentityUser, string> sn = new SignInManager<IdentityUser, string>(um, owinContext.Authentication);
 SignInStatus result = sn.PasswordSignIn<IdentityUser, string>(model.UserName, model.Password, true, true);
 if (result == SignInStatus.Success)
 {

 return RedirectToLocal(returnUrl);
 }

求大神指教,我哪里做错了-_-


原来是startup.cs 没配置好,醉醉的

【热门文章】
【热门文章】