Dave Mateer
Dave Mateer

Reputation: 17946

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?

Upvotes: 18

Views: 18621

Answers (4)

Bob The Janitor
Bob The Janitor

Reputation: 20802

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.

Upvotes: 2

mikus
mikus

Reputation: 3215

check if your server uses the same configuration file for your website (if the config file deployed to website dir is the same)

Upvotes: 0

Dave Mateer
Dave Mateer

Reputation: 17946

<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.

Upvotes: 34

Eranga
Eranga

Reputation: 32437

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());
    }

Upvotes: 7

Related Questions