This project demonstrates how to build an ASP.NET Core hosted Blazor WebAssembly app with .NET 8 and how to upgrade existing apps to take advantage of the latest features.
To upgrade an existing ASP.NET Core hosted Blazor WebAssembly app to .NET 8:
- Update the project file to target
net8.0
and package references to the latest .NET 8 versions (commit). - Move content from Client/wwwroot/index.html to Host.razor (commit):
- Update script to blazor.web.js.
- Replace
title
tag withHeadOutlet
component.
- Update Client/Program.cs (commit):
- Remove
builder.RootComponents.Add<HeadOutlet>("head::after")
.
- Remove
- Update Server/Program.cs (commit):
- Add
builder.Services.AddRazorComponents().AddWebAssemblyComponents()
. - Remove
app.UseBlazorFrameworkFiles()
. - Replace
MapFallbackToFile("index.html")
withapp.MapRazorComponents<Host>().AddWebAssemblyRenderMode()
.
- Add
To enable prerendering:
- Update all components to support prerendering from the server (commit).
- In Host.razor replace the
id=app
tag with<App @rendermode="@RenderMode.WebAssembly" />
(commit).
Open issues: