5

I had to take over an MVC 3 project from another developer. One of the first things he did was to stop the yellow screen of death so that all exceptions are only logged to a file. You now only get a generic message saying an error has occurred.

I would like to switch it back on (since it gets really annoying having to check through the logfiles the whole time) - how do I do this.

I checked through the web.config but I can't see where this happens.

I did try doing customerrors=off, but that didn't do anything. Also removed the global error handling attribute, didn't do anything.

On further clarification, it seems if an exception occurs in a controller I do get the yellow screen of death, but if it occurs in a (razor) view I just get a standard generic error.

You can see the web.config here You can see the global.asax here

Jaco Pretorius
  • 24,380
  • 11
  • 62
  • 94
  • My guess is that he implemented a global exception handler. If that's what he did, all you need to do is unhook the handler, and you should get your yellow screen back. You can read about it here: http://www.developer.com/net/asp/article.php/961301/Global-Exception-Handling-with-ASPNET.htm – Mia Clarke Feb 09 '11 at 12:38
  • I checked - there is no global exception handler being registered in global.asax – Jaco Pretorius Feb 09 '11 at 13:43

4 Answers4

6

This question is a little old, but maybe this will help someone. In addition to setting <customerErrors mode="Off" />, also set this under <system.webServer>: <httpErrors errorMode="Detailed" />

<system.webServer>
   <httpErrors errorMode="Detailed"/>
</system.webServer>
TheTechGuy
  • 16,560
  • 16
  • 115
  • 136
Chad
  • 1,404
  • 1
  • 18
  • 29
5

Normally you set this in web.config in the customErrors element under system.web. Just try to set mode=Off:

<customErrors mode="Off" />
Jan
  • 15,802
  • 5
  • 35
  • 59
4

In Global.asax you can remove filters.Add(new HandleErrorAttribute()); from public static void RegisterGlobalFilters(GlobalFilterCollection filters).

As pointed out in the comments - the problem was with a Custom Base controller overriding the OnException Method.

Jaco Pretorius
  • 24,380
  • 11
  • 62
  • 94
Filip Ekberg
  • 36,033
  • 20
  • 126
  • 183
1

None of this worked for me. Check if someone might have added code to clear the error in the application error event handler.

    protected void Application_Error(object sender, EventArgs e)
    {
        Exception lastException = Server.GetLastError().GetBaseException();

        Log.Error("Global.asax: WebApplication error", lastException);

        //****Server.ClearError();
    }
Fabio Milheiro
  • 8,100
  • 17
  • 57
  • 96