Skip to content

Commit 82bb6b7

Browse files
committed
Add a migration scenario for Blazor
1 parent 70cc81b commit 82bb6b7

File tree

1 file changed

+29
-1
lines changed
  • aspnetcore/migration/80-to-90/includes

1 file changed

+29
-1
lines changed
Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
Blazor migration guidance will appear here prior to the release of .NET 9, which is scheduled for November, 2024.
1+
### Adopt simplified authentication state serialization for Blazor Web Apps
2+
3+
Blazor Web Apps can optionally adopt [simplified authentication state serialization](xref:aspnetcore-9#simplified-authentication-state-serialization-for-blazor-web-apps).
4+
5+
In the server project:
6+
7+
* Remove the Persisting Authentication State Provider (`PersistingAuthenticationStateProvider.cs`).
8+
9+
* Remove the service registration from the `Program` file. Instead, chain a call to <xref:Microsoft.Extensions.DependencyInjection.WebAssemblyRazorComponentsBuilderExtensions.AddAuthenticationStateSerialization%2A> on <xref:Microsoft.Extensions.DependencyInjection.RazorComponentsServiceCollectionExtensions.AddRazorComponents%2A>:
10+
11+
```diff
12+
- builder.Services.AddScoped<AuthenticationStateProvider, PersistingAuthenticationStateProvider>();
13+
14+
builder.Services.AddRazorComponents()
15+
.AddInteractiveServerComponents()
16+
.AddInteractiveWebAssemblyComponents()
17+
+ .AddAuthenticationStateSerialization();
18+
```
19+
20+
In the client project (`.Client`):
21+
22+
* Remove the Persistent Authentication State Provider (`PersistentAuthenticationStateProvider.cs`).
23+
24+
* Remove the service registration from the `Program` file. Instead, call <xref:Microsoft.Extensions.DependencyInjection.WebAssemblyAuthenticationServiceCollectionExtensions.AddAuthenticationStateDeserialization%2A> on the service collection:
25+
26+
```diff
27+
- builder.Services.AddSingleton<AuthenticationStateProvider, PersistentAuthenticationStateProvider>();
28+
+ builder.Services.AddAuthenticationStateDeserialization();
29+
```

0 commit comments

Comments
 (0)