I\'m trying to get the user id in an ASP.NET Core 2.1 MVC project.
However, I was only able to get the email. I\'m almost sure there has to be a 1/2 line way to get
In Asp.net Core 2.2, I solved this problem with the following piece of code.
using Microsoft.AspNetCore.Identity;
var user = await _userManager.FindByEmailAsync(User.Identity.Name);
This way you will get the user information by his email. User.Identity.Name
will provide you the email address of the current logged in user.
I hope this will be useful to someone.