6

From a fresh MVC 3 Project, I've modified an Index() action to throw an exception. I expect the stock Error.chhtml view to be rendered, because I've set <customErrors mode="On" /> in the web.config. Instead, I still get the "yellow screen of death" while running from within VS.

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

My HandleError attribute is set globally from the global.asax.cs.

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

...unmodified, per the default project setup. I've run against both IIS express and VS Dev Server. Nothing causes the custom error page to surface. What am I missing?

tereško
  • 58,060
  • 25
  • 98
  • 150
Brent Arias
  • 29,277
  • 40
  • 133
  • 234
  • It seems working with me just the `` set, the Shared > Error.aspx is being shown up when exception occurs in the application. My Global.asax code is as is what it is, I don't have the `RegisterGlobalFilters` method not like your code. – Peyton Crow May 23 '11 at 05:05

3 Answers3

8

I have seen the same problem, which is due to that I added customErrors mode="On" > to <root>\Views\Web.config, instead of <root>\Web.config

General Grievance
  • 4,555
  • 31
  • 31
  • 45
engineforce
  • 2,840
  • 1
  • 23
  • 17
1

What web server are you using? IIS7 uses a different section of the web.config...that may be your problem.

See this: What is the difference between customErrors and httpErrors?

Community
  • 1
  • 1
ctorx
  • 6,841
  • 8
  • 39
  • 53
0
 <system.web>
    <customErrors mode="On" defaultRedirect="Error.html">
        <error statusCode="403" redirect="/Error403" />
        <error statusCode="404" redirect="/Error404" />
        <error statusCode="500" redirect="/Error500" />
    </customErrors>
</system.web>
<system.webServer>
  <httpErrors errorMode="Custom" existingResponse="Auto" defaultResponseMode="ExecuteURL" >
    <remove statusCode="403"/>
    <remove statusCode="404"/>
    <remove statusCode="500"/>
    <error statusCode="403" responseMode="ExecuteURL" path="/Error403" />
    <error statusCode="404" responseMode="ExecuteURL" path="/Error404" />
    <error statusCode="500" responseMode="ExecuteURL" path="/Error500" />
  </httpErrors>
</system.webServer>
Irfons
  • 591
  • 4
  • 3