79206858

Date: 2024-11-20 10:54:12
Score: 1
Natty:
Report link

If anyone bumps into this issue:

In .NET 9 there is now a built in feature for this:

What's new in ASP.NET Core 9.0 Static asset delivery optimization

See also: ASP.NET Core Blazor static files Static asset delivery in server-side Blazor apps

this also works for WASM.

Short version:

Adding Assets

<link rel="stylesheet" href="@Assets["bootstrap/bootstrap.min.css"]" />
<link rel="stylesheet" href="@Assets["app.css"]" />
<link rel="stylesheet" href="@Assets["BlazorSample.styles.css"]" />

Replacing middleware:

+app.MapStaticAssets();
-app.UseStaticFiles();
Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: S Mxller