Skip to content

Commit 2d87bdc

Browse files
Update request-response.md
1 parent 25d5edf commit 2d87bdc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

aspnetcore/fundamentals/middleware/request-response.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to read the request body and write the response body in A
55
monikerRange: '>= aspnetcore-3.0'
66
ms.author: tdykstra
77
ms.custom: mvc
8-
ms.date: 5/29/2019
8+
ms.date: 4/22/2025
99
uid: fundamentals/middleware/request-response
1010
---
1111
# Request and response operations in ASP.NET Core
@@ -70,6 +70,11 @@ These issues are fixable, but the code is becoming progressively more complicate
7070

7171
## Pipelines
7272

73+
When writing directly to `HttpResponse.BodyWriter`, call `PipeWriter.FlushAsync()` manually to ensure the data is flushed to the underlying response stream. Here's why:
74+
75+
* `HttpResponse.BodyWriter` is a `PipeWriter` that buffers data until a flush operation is triggered.
76+
* Calling `FlushAsync` writes the buffered data to the underlying Stream (`HttpResponse.Body`).
77+
*
7378
The following example shows how the same scenario can be handled using a [PipeReader](/dotnet/standard/io/pipelines#pipe):
7479

7580
[!code-csharp[](request-response/samples/3.x/RequestResponseSample/Startup.cs?name=GetListOfStringFromPipe)]

0 commit comments

Comments
 (0)