Using the standard Blazor Server with individual accounts scaffolded by Microsoft, how do I access the logged in userId inside of a component? .NET 5.
I've tried tapping into AuthenticationStateProvider and using this to get it, but that returns null.
var authState = await authenticationStateProvider.GetAuthenticationStateAsync();
if (authState.User.Identity.IsAuthenticated)
{
var id = authState.User.FindFirst(c => c.Type == "nameidentifier")?.Value;
}
ClaimTypes.NameIdentifierconstant, not a magic string.User.FindFirstValue(ClaimTypes.NameIdentifier)