一个 ASP.NET Core 7.0 MVC 项目,出现 500 错误时没有显示自定义错误页面,而是返回 ProblemDetails,请问如何禁用 ProblemDetails?
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.6.1",
"title": "An error occurred while processing your request.",
"status": 500,
"detail": "The partial view \u0027_NewContent\u0027 was not found. ",
"traceId": "00-aec1852dcad43c38135061b096ea6f55-a01cd318566070fa-00"
}
``
是一个低级错误引起的,将
app.UseCustomErrorPages();
误写成了
app.UseCustomApiErrorPages();
注:这2个扩展方法是我们自己实现的。