A free and open-source web framework that enables developers to create web apps using C# and HTML, developed by Microsoft.
your issue is that User (and database access) are only available server side during the static pre-render. in client you use the AuthenticationStateProvider to access user information. any additional information you want must be added as a claim during authentication (see adding custom claims).
you appear to be using individual, so you are using razor pages to authenticate. you will need to write server middleware that replaces the user principal with one with the additional clams
your other option is to create a custom AuthenticationStateProvider that adds the claims:
the server state must be persisted to the client:
server code:
builder.Services.AddRazorComponents()
.AddInteractiveWebAssemblyComponents()
.AddAuthenticationStateSerialization(
options => options.SerializeAllClaims = true);
client (wasm) code:
builder.Services.AddAuthorizationCore();
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddAuthenticationStateDeserialization();