Skip to content

Commit

Permalink
Merge pull request aspnet#33 from AspNetSmurfLab/master
Browse files Browse the repository at this point in the history
Fix error & debug middleware
  • Loading branch information
DamianEdwards committed Dec 2, 2015
2 parents 4a72030 + f7bbc7f commit e742afb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/Benchmarks/DebugInfoPageMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@ public async Task Invoke(HttpContext httpContext)
await httpContext.Response.WriteAsync($"<li>Configuration: {_configurationName}</li>");
await httpContext.Response.WriteAsync($"<li>Server: {_hostingEnv.Configuration["server"]}</li>");
await httpContext.Response.WriteAsync($"<li>Server URLs: {_hostingEnv.Configuration["server.urls"]}</li>");
await httpContext.Response.WriteAsync($"<li>Supports Send File: {httpContext.Response.SupportsSendFile()}</li>");

await httpContext.Response.WriteAsync($"<li>Server features:<ol>");
await httpContext.Response.WriteAsync($"<li>Server features:<ul>");

foreach (var feature in httpContext.Features)
{
await httpContext.Response.WriteAsync($"<li>{feature.Key.Name}</li>");
}
await httpContext.Response.WriteAsync($"</ol></li>");
await httpContext.Response.WriteAsync($"</ul></li>");

await httpContext.Response.WriteAsync("</ul>");

return;
}

Expand Down
9 changes: 7 additions & 2 deletions src/Benchmarks/ErrorHandlerMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ public async Task Invoke(HttpContext httpContext)
}
catch (Exception ex)
{
httpContext.Response.StatusCode = StatusCodes.Status500InternalServerError;
httpContext.Response.ContentType = "text/html";
if (!httpContext.Response.HasStarted)
{
httpContext.Response.Clear();
httpContext.Response.StatusCode = StatusCodes.Status500InternalServerError;
httpContext.Response.ContentType = "text/html";
}

await httpContext.Response.WriteAsync($"<pre style='color:red'>{ex.ToString()}</pre>");
}
}
Expand Down

0 comments on commit e742afb

Please sign in to comment.