LOGIC Library

This site is the Logic involvement in sharing expertise and skills acquired in daily work. The goal is to create a solid knowledge base and share best practices in software development and systems management.

More info about us can be found on logicsistemi.it.

There was an error processing the request

While running and ASP.NET MVC application on a production server, we could encounter the following error: There was an error processing the request. In this article, we understand what it means and how to have more information about the error.

This is a generic error message and if our only goal is to have the classic runtime error page like the development machine, you just have to add the following line on your Web.config file (the one on the root, not the one under the /Views folder):

        <customErrors mode="Off" />

Pay attention, because what I've just written is case sensitive (the letter "O" in "Off" is uppercase!). Besides, consider that this configuration means that everybody can see complete exception information (you can find on Internet many articles about this setting). Anyway, this way you can discover the real error that caused the exception.

Some more details

But where the message "There was an error processing the request" comes from? Let's suppose we have not made the configuration explained above.

Everything starts in your Global.asax.cs file:

public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    filters.Add(new HandleErrorAttribute());

This line of code adds a filter that is applied to every action (of every controller) that throws an unhandled exception. Without any other parameter, this filter redirects to the view /Views/Shared/Error.cshtml where you can find the phrase "There was an error processing the request".

You can edit Error.cshtml as you want and you can use the HandleErrorInfo class in order to get or display some more information. Here's an example:

@model System.Web.Mvc.HandleErrorInfo
    Error: @Model.Exception.Message