im using .Net9 Blazor i Have Two Authentication Scheme and default is jwt and second is Cookie configured as follows :
im removed some configuration to simplified code as well
builder.Services. AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme);in component :
@attribute [Authorize(AuthenticationSchemes = CookieAuthenticationDefaults.AuthenticationScheme)]<AuthorizeView> @context.User.Identity.IsAuthenticated</AuthorizeView>[CascadingParameter] Task<AuthenticationState> AuthenticationState { get; set; } protected override async Task OnInitializedAsync() { if (AuthenticationState is not null) { var authResult= await AuthenticationState; authResult.User.Identity.IsAuthenticated //is false } }in both AuthorizeView and authResult.User.Identity.IsAuthenticated IsAuthenticated always return false
but if i changed Auth Config as follows everything work fine
builder.Services. AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme);but i need multiple Authentication together