问题是:为什么自定义错误处理不适用于不存在的路径/目录?
更新了固定代码(感谢大家为您输入):
*更新了web.config和global.asax *的代码
<httpErrors errorMode="Custom">
<remove statusCode="500" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/*****.aspx" responseMode="ExecuteURL" />
<error statusCode="500" subStatusCode="-1" prefixLanguageFilePath="" path="/*****.aspx" responseMode="ExecuteURL"/>
</httpErrors>
added this to the global.asax to stop IIS from handling my 500 errors
after @Kev's suggestions IIS handled my 500's these lines fixed that
HttpApplication myApplication = new HttpApplication();
myApplication.Response.TrySkipIisCustomErrors = true;
Run Code Online (Sandbox Code Playgroud)
我们有一个站点设置自定义错误处理web.config
和global.asax
(设置如下图所示).我们能够毫无问题地处理所有404和500.错误被记录Application_Error
在global.asax
,记录到数据库然后使用HttpContext
我们设置状态代码并用于Server.Transfer()
将用户移动到相应的错误页面(重定向导致302,并伤害搜索引擎优化).
问题是当用户键入http://www.example.com/whatever
空白页面时显示在Firefox中,而在IE中显示IE 404页面.Firebug没有显示被激活的状态代码,当我调试解决方案时,我没有设置任何断点global.asax
.奇怪的是,用户可以输入 …