我在web.config中有这个:
<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>
Run Code Online (Sandbox Code Playgroud)
但IIS仍显示内置错误页面.
有任何想法吗?
小智 19
您可能还需要在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>
Run Code Online (Sandbox Code Playgroud)
这就是我使用它的方式,它对我有用,除了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>
Run Code Online (Sandbox Code Playgroud)
小智 5
如果您使用的是 ExecuteURL,则自定义错误页面路径必须与应用程序本身位于同一应用程序池中。
出于体系结构的原因,IIS 7.0 只能执行位于同一应用程序池中的 URL。使用重定向功能在不同的应用程序池中执行自定义错误。
| 归档时间: |
|
| 查看次数: |
19393 次 |
| 最近记录: |