Skip to content

Commit 9d627a3

Browse files
committed
Fixed a error #6 “Incompatible with DeveloperExceptionPageMiddleware (ASP.NET 5)”
1 parent b3b59db commit 9d627a3

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

samples/WebMarkupMin.Sample.AspNet5.Mvc6/Controllers/HomeController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ public IActionResult Sitemap()
8989
};
9090
}
9191

92+
public IActionResult Error()
93+
{
94+
return View();
95+
}
96+
9297
[NonAction]
9398
private string GetAbsoluteUrl(string controllerName, string actionName)
9499
{

samples/WebMarkupMin.Sample.AspNet5Core.Mvc6/Controllers/HomeController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ public IActionResult Sitemap()
8989
};
9090
}
9191

92+
public IActionResult Error()
93+
{
94+
return View();
95+
}
96+
9297
[NonAction]
9398
private string GetAbsoluteUrl(string controllerName, string actionName)
9499
{

src/WebMarkupMin.AspNet5/WebMarkupMinMiddleware.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,17 @@ public async Task Invoke(HttpContext context)
107107
Stream originalStream = response.Body;
108108
response.Body = cacheStream;
109109

110-
await _next.Invoke(context);
110+
try
111+
{
112+
await _next.Invoke(context);
113+
}
114+
catch (Exception)
115+
{
116+
response.Body = originalStream;
117+
cacheStream.SetLength(0);
118+
119+
throw;
120+
}
111121

112122
byte[] cacheBytes = cacheStream.ToArray();
113123
int cacheSize = cacheBytes.Length;

0 commit comments

Comments
 (0)