Net8BlazorServer
Net8BlazorServer copied to clipboard
Blazor Server app with .NET 8
Blazor Server in .NET 8
This project demonstrates how to upgrade Blazor Server apps to .NET 8 and take advantage of the latest Blazor features.
To upgrade an existing Blazor Server app to .NET 8:
- Update the project file to target
net8.0and package references to the latest .NET 8 versions. - Move the contents of App.razor to Routes.razor.
- Move content from Pages/_Host.cshtml to App.razor:
- Update script to blazor.web.js.
- Replace tag helpers with Blazor equivalents.
- Update Program.cs:
- Replace
AddServerSideBlazor()withAddRazorComponents().AddInteractiveServerComponents(). - Add
app.UseAntiforgery(). - Replace
MapBlazorHub()withMapRazorComponents<App>().AddInteractiveServerRenderMode(). - Remove
app.MapFallbackToPage("/_Host");.
- Replace