diff --git a/aspnetcore/migration/80-to-90/includes/blazor.md b/aspnetcore/migration/80-to-90/includes/blazor.md index af0404f9ffa6..2b91b487fd7d 100644 --- a/aspnetcore/migration/80-to-90/includes/blazor.md +++ b/aspnetcore/migration/80-to-90/includes/blazor.md @@ -1 +1,37 @@ -Blazor migration guidance will appear here prior to the release of .NET 9, which is scheduled for November, 2024. +### Adopt simplified authentication state serialization for Blazor Web Apps + +Blazor Web Apps can optionally adopt [simplified authentication state serialization](xref:aspnetcore-9#simplified-authentication-state-serialization-for-blazor-web-apps). + +In the server project: + +* Remove the Persisting Authentication State Provider (`PersistingAuthenticationStateProvider.cs`). + +* Remove the service registration from the `Program` file. Instead, chain a call to on : + + ```diff + - builder.Services.AddScoped(); + + builder.Services.AddRazorComponents() + .AddInteractiveServerComponents() + .AddInteractiveWebAssemblyComponents() + + .AddAuthenticationStateSerialization(); + ``` + +The API only serializes the server-side name and role claims for access in the browser. To include all claims, set to `true`: + +```csharp +.AddAuthenticationStateSerialization(options => options.SerializeAllClaims = true); +``` + +In the client project (`.Client`): + +* Remove the Persistent Authentication State Provider (`PersistentAuthenticationStateProvider.cs`). + +* Remove the service registration from the `Program` file. Instead, call on the service collection: + + ```diff + - builder.Services.AddSingleton(); + + builder.Services.AddAuthenticationStateDeserialization(); + ``` + +For more information, see .