Authentication and Authorization Enhancements in .NET 9.0

Hi @andrea.chiarelli
Thank you for your reply.
I think I did not explain my problem clearly. Let me try to provide a more detailed and precise explanation.
As you know the Visual Studio 2022 Blazor WebApp sample template for Auto Interactive render mode with Individual Accounts as authentication type uses ASP.NET Core Identity. In this setup, it generates a set of pages in a static server-side rendering mode, also known as Prerendering mode, and utilizes ASP NET Core Identity classes such as SignInManager and UserManager to handle authentication. It does not create a custom AuthenticationStateProvider (as all related tasks appear to be handled internally). Instead, it uses AddAuthenticationStateSerialization() and AddAuthenticationStateDeserialization() to transfer the authentication state from Prerendering mode to Interactive rendering mode.

I want to use a similar approach but with an external (remote) API for authentication. This means my Blazor WebApp project will not include ASP NET Core Identity. Instead, I will retrieve a JWT from an external API when the user successfully authenticates. I would like to follow the VS template’s approach by keeping my login and register Razor pages in static server-side rendering mode and transferring the authentication state to Interactive rendering mode using the mentioned serialization methods.
But it seems that to manually notify the Authentication State change or also store a JWT in local storage or a cookie, I need to create a custom AuthenticationStateProvider. However, when my Blazor app is in interactive mode, it attempts to retrieve the authentication state from the overridden GetAuthenticationStateAsync() method in my custom provider, rather than using the already persisted state provided by AddAuthenticationStateSerialization().

Please review the sample project I have shared with you at the following link :pray::
my sample project

Thank you for your assistance!