When should I use HttpContext.User.Identity.IsAuthenticated and SignInManager.IsSignedIn (HttpContext.User)?

There seems to be some ambiguity regarding these 2. I use them interchangeably throughout my project, and the only reason is that I could not figure out when to use one or the other.

What will be the cases when one is true and the other is not?

If I were to use only the ASP.NET identifier to authenticate users, would one or the other be more favorable, or would it not really matter?

+4
source share
1 answer
  • HttpContext.User.Identity.IsAuthenticated , (true, , - false). : HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity("SomeAuthType")); (, JwtBearer), .
  • SignInManager - aspnet, , cookie . , : return principal?.Identities != null && principal.Identities.Any(i => i.AuthenticationType == Options.Cookies.ApplicationCookieAuthenticationScheme);.

, aspnet , aspnet ( app.UseIdentity()), SignInManager.IsSignedIn. aspnet , , HttpContext.User.Identity.IsAuthenticated.

+5

Source: https://habr.com/ru/post/1651988/


All Articles