using Microsoft.AspNetCore.Components.Authorization;
[Inject]
public AuthenticationStateProvider AuthenticationStateProvider { get; set; }
protected override async Task OnInitializedAsync()
{
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
var user = authState.User;
Console.WriteLine("user.Identity.Name: " + user.Identity.Name);
}
Comments