-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Open
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-static-web-assetsquestion
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
app.UseStaticFiles(new StaticFileOptions()
{
OnPrepareResponse = ctx =>
{
if (ctx.Context.Request.Path.Value.Contains("/ui/"))//Do not use StartWithSegments here!
{
if (!ctx.Context.User.Identity.IsAuthenticated)
{
ctx.Context.Abort();
ctx.Context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return;
}
}
},
})
app.MapStaticAssets();
When using MapStaticAssets after UseStaticFiles, the code inside UseStaticFiles (OnPrepareResponse) is not get called
Expected Behavior
The goal is to use both features
For certain static files, use logic in UseStaticFiles, otherwise use MapStaticAssets
Steps To Reproduce
Put breakpoint inside OnPrepareResponse, it won't be hit if there is app.MapStaticAssets
Exceptions (if any)
No response
.NET Version
9.0.0
Anything else?
No response
Bustillox, austinw-fineart and boukenka
Metadata
Metadata
Assignees
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-static-web-assetsquestion