How To Get Current User in a Blazor component

Let’s assume you have configured Blazor authentication and authorization in your project, and you want to access the username/claim in your view. Then, you can wrap the component into AuthorizeView and access the User details from the @context property.

@context property will be not available if the component is not inside the AuthorizeView

    Hello, @context.User.Identity.Name!
Next Post Previous Post
No Comment
Add Comment
comment url