Can't set StatusCode after Response has started (#200)

This commit is contained in:
kinglionsoft 2018-01-16 15:10:52 +08:00 committed by Tom Pallister
parent 31f526d3cd
commit 0784954971

View File

@ -85,7 +85,10 @@ namespace Ocelot.Errors.Middleware
private void SetInternalServerErrorOnResponse(HttpContext context) private void SetInternalServerErrorOnResponse(HttpContext context)
{ {
context.Response.StatusCode = 500; if (!context.Response.HasStarted)
{
context.Response.StatusCode = 500;
}
} }
private string CreateMessage(HttpContext context, Exception e) private string CreateMessage(HttpContext context, Exception e)