请参阅我的代码:
var result = await SignInManager.PasswordSignInAsync(model.UserName,model.Password,model.RememberMe,shouldLockout: false); switch (result) { case SignInStatus.Success: string UserId = User.Identity.GetUserId(); return RedirectToAction("ClientDetails","Home"); case SignInStatus.LockedOut: return View("Lockout"); case SignInStatus.RequiresVerification: return RedirectToAction("SendCode","Account",new { ReturnUrl = returnUrl,RememberMe = model.RememberMe }); case SignInStatus.Failure: default: ModelState.AddModelError("","Invalid login attempt."); return View(model); }
UserId始终为空,User.Identity.IsAuthenticated始终为false.但是我可以查看需要身份验证的View ClientDetails.