我有一个简单的 .NET Core 2.0 项目。这是配置方法:
public void Configure(IApplicationBuilder app, IHostingEnvironment environment)
{
app.UseStatusCodePagesWithReExecute("/error/{0}.html");
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action?}/{id?}",
defaults: new { controller = "Home", action = "Index" });
});
}
Run Code Online (Sandbox Code Playgroud)
当我输入无效 url 时,/error/404.html 会按预期显示,但浏览器会收到 200 状态代码,而不是预期的 404 状态。
我究竟做错了什么?我可以不使用静态 html 文件作为错误页面吗?
asp.net-core ×1