UseStatusCodePagesWithReExecute incorrect description
Hello!
The Handle errors in ASP.NET Core article explicilty states:
The UseStatusCodePagesWithReExecute extension method:
- Returns the original status code to the client.
- Generates the response body by re-executing the request pipeline using an alternate path.
... and later once again:
This method is commonly used when the app should:
- Process the request without redirecting to a different endpoint. For web apps, the client's browser address bar reflects the originally requested endpoint.
- Preserve and return the original status code with the response.
Meanwhile real-life tests show that the status code is not being preserved, only path and query are. We originally thought that this is a bug of StatusCodePagesMiddleware because such behavior is unintuitive. And even though our suspections are confirmed by several articles and posts from previous years (like this 2017 article or this 2018 GitHub comment), this recent 2022 GitHub issue comment clarifies that status code preservation is not intended, so this is not a bug.
If the current behavior is actually intentional then this part of the article needs to be fixed to not confuse anyone.
But if the behavior described by the article is the correct one and the 2022 commenter has made a mistake (which would have been good, because we are now forced to invent workarounds for using ReExecute in combination with StaticFiles just like this post's author) then a bugfix is required.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 0e03fdf4-b19b-17c3-04f4-336ab6d2ee06
- Version Independent ID: 38515dfb-91a5-b395-db9d-084bbaf095c8
- Content: Handle errors in ASP.NET Core
- Content Source: aspnetcore/fundamentals/error-handling.md
- Product: aspnet-core
- Technology: aspnetcore-fundamentals
- GitHub Login: @Rick-Anderson
- Microsoft Alias: riande