HTTPError这样IIS时添加的默认路径为config抛出异常 [英] HttpError iis config throws exception when default path is added
问题描述
我有这个配置哪些工作正确重定向以下错误
I have this config which works and redirects the following errors correctly
<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>
但是,当我添加下面的默认路径尝试添加一个包罗万象的
But when I add the following default path to try to add a catch all
<httpErrors errorMode="Custom"
existingResponse="Replace"
defaultResponseMode="ExecuteURL"
defaultPath="/Error/ApplicationError">
服务器抛出一个web.config误差
The server throws a web.config error
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
现在这直接违背MSDN上的文档
Now this directly contradicts the documentation on msdn
任何帮助将大大AP preciated !!
Any help would be greatly appreciated!!
推荐答案
使用的 defaultPath 的属性 prevents 使用的路径的属性在你的错误的节点。所以下面的配置将工作(当然,它会显示同样的错误页面,这里定义的所有HTTP错误):
Using of defaultPath attribute prevents using of path attribute in your error nodes. So below configuration will work (but of course it will show the same error page for all HTTP errors defined here):
<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
这篇关于HTTPError这样IIS时添加的默认路径为config抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!