Skip to content

MapStaticAssets doesn't work with WebApplication.CreateSlimBuilder #58986

Open
@NoahStahl

Description

@NoahStahl

Describe the bug

In an app built with WebApplication.CreateSlimBuilder() and using the new MapStaticAssets in .NET 9, responses for static files are empty with 200 status code. To reproduce, create a new ASPNET Core project from template, then change WebApplication.CreateBuilder() to WebApplication.CreateSlimBuilder() in Program.cs.

It appears that calling UseStaticWebAssets allows this to work, but this isn't documented as far as I can tell.

// Program.cs
var builder = WebApplication.CreateSlimBuilder(args);
builder.WebHost.UseStaticWebAssets();
var app = builder.Build();
...
app.MapStaticAssets();

Would like to understand what is expected and what the correct setup should be. It seems that if CreateSlimBuilder alone isn't sufficient, there should be some kind of warning visible to developer. At the very least, this aspect should be documented.

Expected Behavior

Either MapStaticAssets truly works as a "drop-in replacelement" of UseWebStaticFiles, or incompatbilities are documented and/or warned to developer in tooling/build.

.NET Version

9.0.100

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions