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?

1
  • It seems working with me just the <customErrors moode="On" /> 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. Commented May 23, 2011 at 5:05

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

Comments

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?

2 Comments

IIS Express presumably is a IIS7 simulation
Yes, I have to use IIS Express with my MVC3 app so that the behavior of my dev error messages is consistent with my production site.
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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.