I'm currently creating a Blazor web application (client + server). User authentication is managed using ASP.NET Core Identity with a SQL Server database.
The issue I face is the value of _userId keeps on changing with each refresh, so I'm unable to track the state of the user using the same.
protected override async Task OnInitializedAsync(){ var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); user = authState.User; var _userId = user.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value;}