Skip to content

Commit 8c8490f

Browse files
committed
[Fixes #112] BaseView.ExecuteAsync disposes the response stream
1 parent f7e7ce5 commit 8c8490f

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

src/Microsoft.AspNet.Diagnostics/Views/BaseView.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Globalization;
77
using System.IO;
88
using System.Linq;
9+
using System.Text;
910
using System.Threading.Tasks;
1011
using Microsoft.AspNet.Http;
1112
using Microsoft.Framework.Internal;
@@ -52,7 +53,7 @@ public async Task ExecuteAsync(HttpContext context)
5253
Context = context;
5354
Request = Context.Request;
5455
Response = Context.Response;
55-
Output = new StreamWriter(Response.Body);
56+
Output = new StreamWriter(Response.Body, Encoding.UTF8, 4096, leaveOpen: true);
5657
HtmlEncoder = context.ApplicationServices.GetHtmlEncoder();
5758
await ExecuteAsync();
5859
Output.Dispose();
@@ -199,7 +200,7 @@ protected void Write(HelperResult result)
199200
/// <param name="value">The <see cref="object"/> to write.</param>
200201
/// <remarks>
201202
/// <see cref="HelperResult.WriteTo(TextWriter)"/> is invoked for <see cref="HelperResult"/> types.
202-
/// For all other types, the encoded result of <see cref="object.ToString"/> is written to the
203+
/// For all other types, the encoded result of <see cref="object.ToString"/> is written to the
203204
/// <paramref name="writer"/>.
204205
/// </remarks>
205206
protected void WriteTo(TextWriter writer, object value)

src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public override async Task ExecuteAsync()
5151
#line 10 "CompilationErrorPage.cshtml"
5252

5353
Response.StatusCode = 500;
54-
Response.ContentType = "text/html";
54+
Response.ContentType = "text/html; charset=utf-8";
5555
Response.ContentLength = null; // Clear any prior Content-Length
5656

5757
#line default

src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
@{
1111
Response.StatusCode = 500;
12-
Response.ContentType = "text/html";
12+
Response.ContentType = "text/html; charset=utf-8";
1313
Response.ContentLength = null; // Clear any prior Content-Length
1414
}
1515
<!DOCTYPE html>

src/Microsoft.AspNet.Diagnostics/Views/ErrorPage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public override async Task ExecuteAsync()
5757

5858
Response.StatusCode = 500;
5959
// TODO: Response.ReasonPhrase = "Internal Server Error";
60-
Response.ContentType = "text/html";
60+
Response.ContentType = "text/html; charset=utf-8";
6161
Response.ContentLength = null; // Clear any prior Content-Length
6262
string location = string.Empty;
6363

src/Microsoft.AspNet.Diagnostics/Views/ErrorPage.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@{
1616
Response.StatusCode = 500;
1717
// TODO: Response.ReasonPhrase = "Internal Server Error";
18-
Response.ContentType = "text/html";
18+
Response.ContentType = "text/html; charset=utf-8";
1919
Response.ContentLength = null; // Clear any prior Content-Length
2020
string location = string.Empty;
2121
}

0 commit comments

Comments
 (0)