-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Open
Labels
area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresfeature-static-files
Description
Unexpected behavior with Blazor Server and .NET 9 on Ubuntu 24
I have a service running on Ubuntu 24 that launches a Blazor web app via command line:
ProcessStartInfo dotnet MyWebApp.dll --urls "http://*:12345"
Like this

Problem
All static assets return 404.
Service location: /opt/clustiis.host
Website location: /opt/wwwroot/proxiweb
The site tries to load its static assets from:
/opt/clustiis.host/wwwroot
instead of:
/opt/wwwroot/proxiweb/wwwroot
I find this behavior surprising.
Workaround
Manually configure the root directory location in Program.cs:
var entryAssembly = System.Reflection.Assembly.GetEntryAssembly();
var currentPath = Path.GetDirectoryName(entryAssembly!.Location)!;
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(System.IO.Path.Combine(currentPath, "wwwroot"))
});
Environment:
Ubuntu 24
.NET 9
Blazor Server
Metadata
Metadata
Assignees
Labels
area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresfeature-static-files