@using MP.SPEC.Components @using MP.SPEC.Data @using System.Security.Claims @using Microsoft.AspNetCore.Components.Authorization @inject AuthenticationStateProvider AuthenticationStateProvider
@userName
@if (ShowSearch) { }
@code { [CascadingParameter(Name ="ShowSearch")] protected bool ShowSearch { get; set; } private string userName = ""; protected override async Task OnInitializedAsync() { await forceReload(); } private async Task forceReload() { var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); var user = authState.User; if (user.Identity.IsAuthenticated) { userName = $"{user.Identity.Name}"; } else { userName = "N.A."; } } }