Rud*_*dey 6 .net c# asp.net iis asp.net-mvc
我的 Web.config 包含以下内容:
<httpErrors errorMode="Custom" existingResponse="PassThrough">
<clear />
<error statusCode="404" responseMode="ExecuteURL" path="/error" />
<error statusCode="500" responseMode="ExecuteURL" path="/error" />
</httpErrors>
Run Code Online (Sandbox Code Playgroud)
我不想显示默认的 ASP.NET 错误页面,所以我像这样清除我的响应:
protected void Application_EndRequest(object sender, EventArgs e) {
if (Response.StatusCode >= 400) {
Response.Clear();
}
}
Run Code Online (Sandbox Code Playgroud)
这将阻止显示默认的 ASP.NET 错误页面。不幸的是,我的自定义错误页面也没有显示。即使我的响应为空,PassThrough也不会执行我的自定义错误页面路径(未命中断点)。如果我使用existingResponse="Replace",一切正常,但为什么不能使用PassThrough?