Skip to content

Commit 2b63a5f

Browse files
authored
PR feedback (#45677)
- Added a comment about why we skip setting the status code in terminal middleware if the response has started.
1 parent 360cf78 commit 2b63a5f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Http/Http/src/Builder/ApplicationBuilder.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ public RequestDelegate Build()
132132
throw new InvalidOperationException(message);
133133
}
134134

135+
// Flushing the response and calling through to the next middleware in the pipeline is
136+
// a user error, but don't attempt to set the status code if this happens. It leads to a confusing
137+
// behavior where the client response looks fine, but the server side logic results in an exception.
135138
if (!context.Response.HasStarted)
136139
{
137140
context.Response.StatusCode = StatusCodes.Status404NotFound;

0 commit comments

Comments
 (0)