I need to know how to obtain the Id of the logged in user in an asp.net core project, in asp.net mvc5 I obtained it in the following way:
User.Identity.GetUserId();
but here it doesn't work for me.
I need to know how to obtain the Id of the logged in user in an asp.net core project, in asp.net mvc5 I obtained it in the following way:
User.Identity.GetUserId();
but here it doesn't work for me.
You can create an extension method for
ClaimsPrincipal
:And so you could use it:
Source: ASP.NET Core: Get User ID