I have a custom HandleError attribute that deals with errors on the MVC pipeline; I have an protected void Application_Error(object sender, EventArgs e) method on my Global.asax which handles errors from outside the pipeline.
I've come across an scenario I didn't know was possible; In implementing DI, there's a dependency for a connectionString, which is taken from the application configuration file.
As the connection string didn't exist yet, an error raises when creating the controller, this usually makes the Application_Error handler fire, and a proper error page is rendered (through rendering a partial view as string and sending it as the response, and in case this fails it just writes "Fatal exception." to the response.
Except in this case, I get the fugly default ASP.NET "runtime error" yellow screen of death. Telling me:
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed.
Details: To enable the details of this specific error message to be viewable on the local server machine, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "RemoteOnly". To enable the details to be viewable on remote machines, please set "mode" to "Off".
I don't have a defaultRedirect set in my customErrors, nor is it turned Off, because I don't want to redirect but to render errors on the same page the user is in, avoiding a needless redirect.
How can I handle an scenario such as this? And what's even the reason why it behaves this way and not like any other error outside a controller?
I realize it'