Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get detailed error information in ASP.NET MVC website

I just deployed an ASP.NET MVC 3 application to our staging server. Whenever an error occurs, I cannot get the detailed error information, i.e. the "yellow screen of death." Instead, I just get a simple "Sorry, an error occurred while processing your request." message.

My Web.config does include the customErrors off, i.e.:

<system.web>
  <compilation debug="true" targetFramework="4.0">
    <assemblies>
      ...
    </assemblies>
  </compilation>
  <customErrors mode="off"/>
</system.web>

In this case, I know exactly what the underlying error is. (I forgot to set permissions on a stored procedure.) But I really want to (re)enable the error handling so I can find these bugs quickly. Of course, I will remove this once we actually go live for security reasons.

What other settings are there that could be overriding the default ASP.NET error handling?

like image 591
Dave Mateer Avatar asked Jan 30 '12 14:01

Dave Mateer


3 Answers

<customErrors mode="Off"/>

The "Off" must be capitalized correctly.

From "Editing ASP.NET Configuration Files":

Case-Sensitivity

Because tags must be well-formed XML, the tags, subtags, and attributes are case-sensitive. Tag names and attribute names are camel-cased, which means that the first character of a tag name is lowercase and the first letter of any subsequent concatenated word or words is uppercase. In most cases, string attribute values are Pascal-case, which means that the first character is uppercase and the first letter of any subsequent concatenated word or words is uppercase. Exceptions are true and false, which are always lowercase.

Remember kids, you learn something new every day. Even if what you learn is lame.

like image 161
Dave Mateer Avatar answered Oct 01 '22 16:10

Dave Mateer


You may have HandleErrorAttribute global filter in your Global.asax.cs file. Remove that line.

    public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new HandleErrorAttribute());
    }
like image 37
Eranga Avatar answered Oct 01 '22 15:10

Eranga


A better, long term solution may be to add Elmah to your project, it adds detailed logging to your web project.

Including:

  • Logging of nearly all unhandled exceptions.
  • A web page to remotely view the entire log of recoded exceptions.
  • A web page to remotely view the full details of any one logged exception, including colored stack traces.
  • In many cases, you can review the original yellow screen of death that ASP.NET generated for a given exception, even with customErrors mode turned off.
  • An e-mail notification of each error at the time it occurs.
  • An RSS feed of the last 15 errors from the log.
like image 24
Bob The Janitor Avatar answered Oct 01 '22 15:10

Bob The Janitor