From 0784954971025fd820eedc1d656f10c0010063ab Mon Sep 17 00:00:00 2001 From: kinglionsoft Date: Tue, 16 Jan 2018 15:10:52 +0800 Subject: [PATCH] Can't set StatusCode after Response has started (#200) --- src/Ocelot/Errors/Middleware/ExceptionHandlerMiddleware.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddleware.cs b/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddleware.cs index 96f2ca45..abe9ca41 100644 --- a/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddleware.cs +++ b/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddleware.cs @@ -85,7 +85,10 @@ namespace Ocelot.Errors.Middleware private void SetInternalServerErrorOnResponse(HttpContext context) { - context.Response.StatusCode = 500; + if (!context.Response.HasStarted) + { + context.Response.StatusCode = 500; + } } private string CreateMessage(HttpContext context, Exception e)