Use the new Response.Clear() API.

This commit is contained in:
Chris R 2015-09-10 12:09:43 -07:00
parent 8dc4ddf195
commit 27a8002e75
2 changed files with 2 additions and 14 deletions

View File

@ -72,14 +72,8 @@ namespace Microsoft.AspNet.Diagnostics
try
{
context.Response.Clear();
context.Response.StatusCode = 500;
context.Response.Headers.Clear();
// if buffering is enabled, then clear it as data could have been written into it.
if (context.Response.Body.CanSeek)
{
context.Response.Body.SetLength(0);
}
await DisplayException(context, ex);
return;

View File

@ -53,21 +53,15 @@ namespace Microsoft.AspNet.Diagnostics
}
try
{
context.Response.Clear();
var exceptionHandlerFeature = new ExceptionHandlerFeature()
{
Error = ex,
};
context.Features.Set<IExceptionHandlerFeature>(exceptionHandlerFeature);
context.Response.StatusCode = 500;
context.Response.Headers.Clear();
context.Response.OnStarting(_clearCacheHeadersDelegate, context.Response);
// if buffering is enabled, then clear it as data could have been written into it.
if (context.Response.Body.CanSeek)
{
context.Response.Body.SetLength(0);
}
await _options.ExceptionHandler(context);
// TODO: Optional re-throw? We'll re-throw the original exception by default if the error handler throws.
return;