Skip to content

Commit e742afb

Browse files
committed
Merge pull request #33 from AspNetSmurfLab/master
Fix error & debug middleware
2 parents 4a72030 + f7bbc7f commit e742afb

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/Benchmarks/DebugInfoPageMiddleware.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,17 @@ public async Task Invoke(HttpContext httpContext)
4848
await httpContext.Response.WriteAsync($"<li>Configuration: {_configurationName}</li>");
4949
await httpContext.Response.WriteAsync($"<li>Server: {_hostingEnv.Configuration["server"]}</li>");
5050
await httpContext.Response.WriteAsync($"<li>Server URLs: {_hostingEnv.Configuration["server.urls"]}</li>");
51+
await httpContext.Response.WriteAsync($"<li>Supports Send File: {httpContext.Response.SupportsSendFile()}</li>");
5152

52-
await httpContext.Response.WriteAsync($"<li>Server features:<ol>");
53+
await httpContext.Response.WriteAsync($"<li>Server features:<ul>");
54+
5355
foreach (var feature in httpContext.Features)
5456
{
5557
await httpContext.Response.WriteAsync($"<li>{feature.Key.Name}</li>");
5658
}
57-
await httpContext.Response.WriteAsync($"</ol></li>");
59+
await httpContext.Response.WriteAsync($"</ul></li>");
5860

5961
await httpContext.Response.WriteAsync("</ul>");
60-
6162
return;
6263
}
6364

src/Benchmarks/ErrorHandlerMiddleware.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ public async Task Invoke(HttpContext httpContext)
2525
}
2626
catch (Exception ex)
2727
{
28-
httpContext.Response.StatusCode = StatusCodes.Status500InternalServerError;
29-
httpContext.Response.ContentType = "text/html";
28+
if (!httpContext.Response.HasStarted)
29+
{
30+
httpContext.Response.Clear();
31+
httpContext.Response.StatusCode = StatusCodes.Status500InternalServerError;
32+
httpContext.Response.ContentType = "text/html";
33+
}
34+
3035
await httpContext.Response.WriteAsync($"<pre style='color:red'>{ex.ToString()}</pre>");
3136
}
3237
}

0 commit comments

Comments
 (0)