【发布时间】:2020-11-11 19:56:23
【问题描述】:
我是 asp.net core 和 C# 的新手,如果我的问题听起来很愚蠢,很抱歉,下面是我的代码:
//startup.cs
...
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
app.UseExceptionHandler("/error.html");
app.Use(async (context, next) => {
await context.Response.WriteAsync("Hello");
await next();
});
app.Run(context => {
throw new Exception("Something has gone wrong");
});
}
我们可以看到最后一个中间件抛出了异常,所以我希望看到我自定义的error.html页面被显示,但我仍然在页面上看到“Hello”并且没有error.html内容,怎么会?
【问题讨论】:
-
既然您想提供静态错误页面this 问题可能会有所帮助。
标签: c# asp.net-core