Use the new Response.Clear() API.
This commit is contained in:
parent
8dc4ddf195
commit
27a8002e75
|
|
@ -72,14 +72,8 @@ namespace Microsoft.AspNet.Diagnostics
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
context.Response.Clear();
|
||||||
context.Response.StatusCode = 500;
|
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);
|
await DisplayException(context, ex);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -53,21 +53,15 @@ namespace Microsoft.AspNet.Diagnostics
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
context.Response.Clear();
|
||||||
var exceptionHandlerFeature = new ExceptionHandlerFeature()
|
var exceptionHandlerFeature = new ExceptionHandlerFeature()
|
||||||
{
|
{
|
||||||
Error = ex,
|
Error = ex,
|
||||||
};
|
};
|
||||||
context.Features.Set<IExceptionHandlerFeature>(exceptionHandlerFeature);
|
context.Features.Set<IExceptionHandlerFeature>(exceptionHandlerFeature);
|
||||||
context.Response.StatusCode = 500;
|
context.Response.StatusCode = 500;
|
||||||
context.Response.Headers.Clear();
|
|
||||||
context.Response.OnStarting(_clearCacheHeadersDelegate, context.Response);
|
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);
|
await _options.ExceptionHandler(context);
|
||||||
// TODO: Optional re-throw? We'll re-throw the original exception by default if the error handler throws.
|
// TODO: Optional re-throw? We'll re-throw the original exception by default if the error handler throws.
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue