简体   繁体   中英

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, ie 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, ie:

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

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

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

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.

检查您的服务器是否为您的网站使用相同的配置文件(如果部署到网站目录的配置文件是相同的)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM