Trying to implement authentication. Here is the method in which I authenticate the user:

private async Task Authenticate(AppUser user) { var claims = new List<Claim> { new Claim(ClaimTypes.Name, user.Id) }; var userIdentity = new ClaimsIdentity(claims, "login"); var principal = new ClaimsPrincipal(userIdentity); await HttpContext.SignInAsync(principal); } 

Below is a line of code with which this user is trying to get in the controller

 var user = await userManager.GetUserAsync(HttpContext.User); 

but I get null

  • all figured out - forgot to add app.UseAuthentication (); - Roman Timokhov

0