using System.Security.Claims; var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
Note that this extension method only works for Users inside controllers, not view components, as the view component User is of IPrincipal.
using System.Security.Claims; var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
Note that this extension method only works for Users inside controllers, not view components, as the view component User is of IPrincipal.