0

我是 ASP.net MVC 的新手。我在 web.config 中将 customErrors 设置为 on,并且 global.ascx.cs 包含以下代码:

public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
    filters.Add(new HandleErrorAttribute());
}

但是当我抛出异常时,我仍然看到显示堆栈跟踪的黄页错误。我还应该做什么?提前感谢任何帮助。

编辑

这是我的 web.config 内容的一部分:

<system.web>
    <customErrors mode="On"/>
    <httpHandlers>
      <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
    </httpHandlers>
    <pages
        validateRequest="false"
        pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc,     Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=3.0.0.0,     Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc,     Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <controls>
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral,     PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
      </controls>
    </pages>
</system.web>
4

1 回答 1

0

If what you want to happen is that the application shows the default Error view, your customErrors config should be:

  <customErrors mode="On" defaultRedirect="Error" />

If you're trying to achieve something else, please provide details.

于 2012-11-28T22:02:13.870 回答