diff --git a/src/Http/Http/src/Builder/ApplicationBuilder.cs b/src/Http/Http/src/Builder/ApplicationBuilder.cs index 3297e2f76f23..f68a2777092d 100644 --- a/src/Http/Http/src/Builder/ApplicationBuilder.cs +++ b/src/Http/Http/src/Builder/ApplicationBuilder.cs @@ -132,6 +132,9 @@ public RequestDelegate Build() throw new InvalidOperationException(message); } + // Flushing the response and calling through to the next middleware in the pipeline is + // a user error, but don't attempt to set the status code if this happens. It leads to a confusing + // behavior where the client response looks fine, but the server side logic results in an exception. if (!context.Response.HasStarted) { context.Response.StatusCode = StatusCodes.Status404NotFound;