Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MapStaticAssets doesn't work with WebApplication.CreateSlimBuilder #58986

Open
NoahStahl opened this issue Nov 15, 2024 · 0 comments
Open

MapStaticAssets doesn't work with WebApplication.CreateSlimBuilder #58986

NoahStahl opened this issue Nov 15, 2024 · 0 comments
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-static-web-assets

Comments

@NoahStahl
Copy link

NoahStahl commented Nov 15, 2024

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

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Nov 15, 2024
@gfoidl gfoidl added feature-static-web-assets area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-static-web-assets
Projects
None yet
Development

No branches or pull requests

2 participants