Figured this out..
It was some boilerplate code left in the Global.asax.cs
when creating the project:
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
In particular:
filters.Add(new HandleErrorAttribute());
This creates an new instance of HandleErrorAttribute
which is applied Globally to all of my views.
With no customization, if a view throws an error while utilizing this attribute, MVC will display the default Error.cshtml
file in the Shared
folder which is where the: "Sorry, an error occurred while processing your request."
came from.
From the documentation on HandleErrorAttribute:
By default, when an action method with the HandleErrorAttribute attribute throws any exception, MVC displays the Error view that is located in the ~/Views/Shared folder.
Commenting this line out solved the problem and allowed me to use custom error pages for 500 errors.