此document说:
我们正在调用 PasswordSignInAsync 来验证并发布 身份验证Cookie
此方法是否确实验证了经过身份验证的Cookie? 验证后会怎样?我该如何获取验证结果?
换句话说:知道用户以身份登录的最佳方法是什么?
答案 0 :(得分:2)
...验证经过身份验证的Cookie
我想这不是该句子的读法。
PasswordSignInAsync验证传递给它的凭据,如果它们有效,它将创建身份验证cookie并将其添加到响应中。
...知道用户以身份登录的方法
身份验证cookie用于在每个请求上重新创建Identity和Principal对象,因此对您问题的简单答案是
User.Identity.IsAuthenticated // this is a Boolean value
如果您想坚持使用SignInManager,请使用IsSignedIn(),其名称如下:
// Assuming you have an instance of SignInManager called _signInManager
_signInManager.IsSignedIn(User);
的内容