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);

        }
Last modified: December 20, 2020

Author

Comments

Write a Reply or Comment