From fbc06caad38af4950d155ab6d4f1c3f09e6186ed Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Sat, 15 May 2021 19:08:19 +0300 Subject: [PATCH] use Response.WriteAsync instead of HttpResponseStreamWriter --- src/Mvc/Mvc.Core/src/ContentResult.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/Mvc/Mvc.Core/src/ContentResult.cs b/src/Mvc/Mvc.Core/src/ContentResult.cs index 060aa72c40bf..c4d8158ac7b2 100644 --- a/src/Mvc/Mvc.Core/src/ContentResult.cs +++ b/src/Mvc/Mvc.Core/src/ContentResult.cs @@ -82,17 +82,7 @@ async Task IResult.ExecuteAsync(HttpContext httpContext) if (Content != null) { response.ContentLength = resolvedContentTypeEncoding.GetByteCount(Content); - - await using (var textWriter = new HttpResponseStreamWriter(response.Body, resolvedContentTypeEncoding)) - { - await textWriter.WriteAsync(Content); - - // Flushing the HttpResponseStreamWriter does not flush the underlying stream. This just flushes - // the buffered text in the writer. - // We do this rather than letting dispose handle it because dispose would call Write and we want - // to call WriteAsync. - await textWriter.FlushAsync(); - } + await response.WriteAsync(Content, resolvedContentTypeEncoding); } } }