UseStatusCodePagesWithReExecute should respect [SkipStatusCodePages] #39472
Labels
area-networking
Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
bug
This issue describes a behavior which is not expected - a bug.
help wanted
Up for grabs. We would accept a PR to help resolve this issue
Milestone
Describe the bug
app.UseStatusCodePagesWithReExecute(string pathFormat)
must come before any explicit call toapp.UseRouting()
in order to redo route matching withpathFormat
. Reversing this order causes requests that should result in a status code page to result in a 404 instead because the route matching is never rerun.The problem is that correctly putting
UseStatusCodePagesWithReExecute
beforeUseRouting
causes[SkipStatusCodePages]
to be ignored. StatusCodePagesMiddlewarechecks for ISkipStatusCodePagesMetadata beforeUseRouting
sets the metadata. (One possible fix might be to check for the metadata again after calling_next
ifGetEndpoint()
returnednull
before calling_next
.)Reversing the order leads to 404s. This is unfortunately by design, but it would be great if we could make this work similar to the way we do for the implicit
UseRouting
inWebApplication
.If
WebApplication
is used instead with its implicit call toUseRouting
, everything works correctly. Rerouting does not 404 and[SkipStatusCodePages]
is respected. This is thanks to @BrennanConroy's work in #35426. Maybe we could do something similar for non-WebApplication
scenarios.More context from previous work in this area: #38509 (comment)
Expected Behavior
[SkipStatusCodePages]
should be respected and rerouting should not 404..NET Version
7.0.100-alpha.1.22060.1
The text was updated successfully, but these errors were encountered: