【问题标题】:HTTP 500, customErrors redirect not workingHTTP 500,customErrors 重定向不起作用
【发布时间】:2012-08-10 09:48:20
【问题描述】:

我正在使用 MVC2。
我的 webconfig 说

<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/internal-server-error">
  <error statusCode="500" redirect="~/internal-server-error" />
  <error statusCode="404" redirect="~/not-found" />
</customErrors>

我的测试方法说

public ActionResult ErrorTest()
{
    var z = 0;
    var x= 3/z;
    return null;
}

我仍然得到默认的运行时错误 Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed.,而不是我的自定义错误方法,它甚至没有被调用。

为什么? 这是一个开发服务器问题吗?它可以在 IIS 上运行吗?

编辑:也在 IIS Express 上尝试过,在 Global.asax.cs 中注释掉了整个 Application_Error,仍然无法正常工作。

【问题讨论】:

    标签: asp.net-mvc iis custom-errors


    【解决方案1】:

    尝试删除redirectMode="ResponseRewrite" 属性

    CustomErrors does not work when setting redirectMode="ResponseRewrite"

    【讨论】:

      猜你喜欢
      • 2014-03-10
      • 2018-06-11
      • 2015-07-28
      • 2019-02-12
      • 2022-01-14
      • 2021-04-15
      • 2018-01-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多