asp.net – HttpError iis config在添加默认路径时抛出异常

我有这个配置工作,并正确重定向以下错误
<httpErrors errorMode="Custom" 
        existingResponse="Replace" 
        defaultResponseMode="ExecuteURL" >
  <remove statusCode="403" />
  <remove statusCode="404" />
  <remove statusCode="500" />
  <error statusCode="403" responseMode="ExecuteURL" path="/Error/AccessDenied" />
  <error statusCode="404" responseMode="ExecuteURL" path="/Error/PageNotFound" />
  <error statusCode="500" responseMode="ExecuteURL" path="/Error/ApplicationError" />
</httpErrors>

但是当我添加以下认路径以尝试添加catch all时

<httpErrors errorMode="Custom" 
        existingResponse="Replace" 
        defaultResponseMode="ExecuteURL" 
        defaultPath="/Error/ApplicationError">

服务器抛出web.config错误

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Module     CustomErrorModule

在这documentation on msdn直接矛盾

任何帮助将不胜感激!!

解决方法

使用defaultPath属性可防止在错误节点中使用path属性.所以下面的配置会起作用(但是当然它会为这里定义的所有HTTP错误显示相同的错误页面):
<httpErrors errorMode="Custom" existingResponse="Replace"
  defaultResponseMode="ExecuteURL" defaultPath="/Error/ApplicationError">
  <remove statusCode="403" />
  <remove statusCode="404" />
  <remove statusCode="500" />
  <error statusCode="403" responseMode="ExecuteURL" />
  <error statusCode="404" responseMode="ExecuteURL" />
  <error statusCode="500" responseMode="ExecuteURL" />
</httpErrors>

相关文档:https://msdn.microsoft.com/en-us/library/ms690576(v=vs.90).aspx

相关文章

这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...
最近用到了CalendarExtender,结果不知道为什么发生了错位,...
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence cha...