Asp.net HttpError将不显示自定义错误页
我在web.config中找到了这个:Asp.net HttpError将不显示自定义错误页,asp.net,iis-7,Asp.net,Iis 7,我在web.config中找到了这个: <httpErrors errorMode="Custom"> <remove statusCode="404" subStatusCode="-1" /> <remove statusCode="500" subStatusCode="-1" /> <error statusCode="404" prefixLanguageFilePath="" path="/Error/NotFound.aspx"
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/Error/NotFound.aspx" responseMode="Redirect" />
<error statusCode="500" prefixLanguageFilePath="" path="/Error/ServerError.aspx" responseMode="Redirect" />
</httpErrors>
但是IIS仍然显示内置错误页面
有什么想法吗?似乎您正在使用服务器相对URL,请尝试从中设置
responseMode=“ExecuteURL”
ExecuteURL
提供动态内容(例如,
路径中指定的.asp文件)
自定义错误的属性。如果
responseMode设置为ExecuteURL,即
路径值必须是服务器相对值
网址。数值为1
重定向
将客户端浏览器重定向到URL中的
在路径属性中指定
包含自定义错误文件。如果
responseMode设置为重定向,则
路径值必须是绝对URL。
数值为2
这就是我使用它的方式,对我来说,它看起来非常相似,除了subStatusCode指令和ExecuteURL
<httpErrors>
<!--Remove inherited 500 error page setting -->
<remove statusCode='500' subStatusCode='-1'/>
<!--Override the inherited 500 error page setting with the 'My500.html' as its path-->
<error statusCode='500' subStatusCode='-1' prefixLanguageFilePath='' path='/My500.html' responseMode='ExecuteURL'/>
</httpErrors>
您可能还需要在httpErrors元素中设置existingReponse属性,如下所示:
<httpErrors errorMode="Custom" existingResponse="Replace">
<clear />
<error statusCode="404" prefixLanguageFilePath="" path="/ErrorHandler.aspx" responseMode="ExecuteURL" />
<error statusCode="500" prefixLanguageFilePath="" path="/ErrorHandler.aspx" responseMode="ExecuteURL" />
</httpErrors>
确保IIS中的错误页面重定向功能设置正确。要检查这一点,请在IIS管理器的“错误页面”页面中,单击“编辑功能设置”,并确保在测试来自web服务器本身的重定向时选中了“自定义错误页面”。如果您正在远程测试,您可以为本地请求留下详细的错误信息,并选中远程请求的自定义错误页面。这似乎是我的测试环境中的默认选项。如果您使用的是ExecuteURL,则自定义错误页路径必须与应用程序本身位于同一应用程序池中
出于体系结构原因,IIS 7.0只能在URL位于同一应用程序池中时执行该URL。使用重定向功能在不同的应用程序池中执行自定义错误
这就是最新的Orchard 1.4出现问题的原因,干杯。@Kiquenet不确定,但自动解决了我的问题。请注意,使用
existingResponse=“Replace”
将替换所有退货。例如,如果您调用一个webapi,它发送一个statuscode=404的返回,这将覆盖答案,请使用existingResponse=“PassThrough”
以获得明确的答案。