【问题标题】:HttpErrors existingResponse="Replace" prevents custom error handling for MVCHttpErrors existingResponse="Replace" 防止 MVC 的自定义错误处理
【发布时间】:2012-07-12 07:48:33
【问题描述】:

我正在使用 MVC3 应用程序中的 [HandleError] 属性处理错误。这工作正常,但要让它工作,我需要添加

<system.web>
     <customErrors mode="On" />

为了处理 404 错误,我将其添加到系统中。webserver 即 IIS 配置而不是 asp.net

<httpErrors errorMode="Custom" existingResponse="Replace">
   <remove statusCode="404" />
   <error statusCode="404" responseMode="ExecuteURL" path="/404page" />
</httpErrors>

这很简单,适用于 404。在这里添加它的原因是它看起来像是一个很好的包罗万象,没有任何自定义代码。 existingResponse="Replace" 是必需的,其他模式导致 404 不被处理。

问题是当existingResponse="Replace" 时CustomErrors 不再起作用。它只是返回一个没有详细信息的剥离 500 错误。

这两种模式是互斥的吗?我知道我可以编写其他 404 解决方案,但理想情况下,我希望这个简单的配置更改能够正常工作或理解为什么它无法完成。

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-3 web-config http-status-code-404


    【解决方案1】:

    不是直接的答案,但发现 this SO solution 对我有用,而不是使用 existingResponse="replace"

    【讨论】:

      猜你喜欢
      • 2012-08-08
      • 2013-08-26
      • 1970-01-01
      • 2010-12-24
      • 2010-09-27
      • 1970-01-01
      • 2010-11-13
      • 2011-06-23
      相关资源
      最近更新 更多