如何添加使用httpErrors默认的错误页面 [英] How to add a default error page using httpErrors

查看:1648
本文介绍了如何添加使用httpErrors默认的错误页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功添加自定义的404页。我想要做的是创建一个显示时,有超过404如其他任何错误的另一个定义错误页500,403等。

这就是我现在在webconfig

 < httpErrors errorMode =自定义existingResponse =替换>
      <清除状态code =404子状态code = - 1/>
      <错误状态code =404路径=/ 404.aspxresponseMode =ExecuteURL/>
    < / httpErrors>


解决方案

哦,我的。我不能相信我无法找到这个简单问题的一个合适的答案!然而,2个小时阅读文档和调试后,我找到了。

 < httpErrors errorMode =自定义existingResponse =自动defaultResponseMode =ExecuteURLdefaultPath =/应用/错误> <! - 不包括〜,这是我的问题都长 - >
  <清/> <! - 让IIS提供的错误页面被跳过 - >
  <! - 添加那些你喜欢你提供的视图 - >
  <错误路径=/应用/ HTTP404responseMode =ExecuteURL状态code =404/>
  <错误路径=/应用/ Http503responseMode =ExecuteURL状态code =503/>
< / httpErrors>

Beaware的< httpErros> 配置IIS,而<的customErrors> 配置ASP.NET和一些老的IIS版本(小于?= 6)。

i have successfully added a custom 404 page. what I want to do is to create another custom error page that is displayed when there is any error other than 404. e.g. 500, 403 etc.

this is what I have right now in webconfig

<httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404" subStatusCode="-1" />
      <error statusCode="404" path="/404.aspx" responseMode="ExecuteURL"/>
    </httpErrors>

解决方案

Oh, my. I cannot believe I could not find a proper answer for this simple question! Nevertheless, after 2 hours of reading the docs and debugging, I found it.

<httpErrors errorMode="Custom" existingResponse="Auto" defaultResponseMode="ExecuteURL" defaultPath="/App/Error"> <!-- Do not include ~, this was my issue all long -->
  <clear/> <!-- so that IIS provided error pages are skipped -->
  <!-- add those which you like to provide a view of yours -->
  <error path="/App/Http404" responseMode="ExecuteURL" statusCode="404"/>
  <error path="/App/Http503" responseMode="ExecuteURL" statusCode="503"/>
</httpErrors>

Beaware that <httpErros> configures IIS, while <customErrors> configures ASP.NET and some older versions of IIS (<=6?).

这篇关于如何添加使用httpErrors默认的错误页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆