-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Expose the original status code in StatusCodeReExecuteFeature #46539
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests?
src/Middleware/Diagnostics.Abstractions/src/IStatusCodeReExecuteFeature.cs
Outdated
Show resolved
Hide resolved
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
...so that it can be used in places like `StaticFileOptions.OnPrepareResponse`. With this change it will be possible to write code like ```csharp app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = responseContext => { var context = responseContext.Context; if (context.Response.StatusCode == StatusCodes.Status200OK && context.Features[typeof(IStatusCodeReExecuteFeature)] is IStatusCodeReExecuteFeature statusCodeFeature) { context.Response.StatusCode = statusCodeFeature.OriginalStatusCode; } } }); ``` Fixes dotnet#46538
Force push is a trivial rebase. API Review changes to follow. |
There aren't any for |
src/Middleware/Diagnostics/src/StatusCodePage/StatusCodeReExecuteFeature.cs
Outdated
Show resolved
Hide resolved
...the other setters in the type should also be internal, but it's too late now.
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Expose the original status code in StatusCodeReExecuteFeature
Expose the original status code in
StatusCodeReExecuteFeature
Description
Expose the original status code in
StatusCodeReExecuteFeature
so that it can be used in places likeStaticFileOptions.OnPrepareResponse
.With this change it will be possible to write code like
Fixes #46538