Home > Mobile >  How to propertly retrieve the user in Blazor
How to propertly retrieve the user in Blazor

Time:07-19

I'am new in Blazor(server) and in ASP.NET Identity. I searched on internet how to retrieve the current logged in user. I'am using ASP.NET IDENTITY with the built-in functions. And I saw people that use SignInMananger and the AuthenticationState, or even the HttpContext. Now my question is: what's the difference, the advantages of using the first over the other?

CodePudding user response:

Use the Authentication State - see this Ms Docs document which you've probably already read : https://docs.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-6.0.

SigninManager isn't really designed to work directly with Blazor - see this document that describes the issues. : https://startblazoring.com/Blog/SignInManager

HttpContext - The default Authentication State Provider does the work for you. It builds the ClaimsPrincipal object that represents the user from the HttpContext.

  • Related