Blazor WebAssembly Upgrade to .NET 10 — Fix for 404 Error

When upgrading a Blazor WebAssembly Hosted app to .NET 10, you might run into this error in the browser console:

Failed to load resource: the server responded with a status of 404 (blazor.web.js:1)

What’s Going On

This happens because the way static files are served in hosted Blazor apps has changed in .NET 10. The old app.UseStaticFiles() middleware no longer correctly maps the WebAssembly client’s static assets.

The Fix

In your Server project’s Program.cs, replace this line:

app.UseStaticFiles();

with the new method:

app.MapStaticAssets();

That’s it — once you make this change, your Blazor app should load without the 404 error.

Reference

This issue and the fix are discussed in detail here:
:backhand_index_pointing_right: GitHub: dotnet/aspnetcore#63962 – Comment by Pranav Krishnamoorthy