I\'m developing a MVC3 base website and I am looking for a solution for handling errors and Render custom Views for each kind of error. So imagine that I have a \"Error\" Co
I see you added a config value for EnableCustomErrorPage and you're also checking IsDebuggingEnabled to determine whether or not to run your error handling.
Since there's already a
protected void Application_Error()
{
if (HttpContext.Current == null)
{
// errors in Application_Start will end up here
}
else if (HttpContext.Current.IsCustomErrorEnabled)
{
// custom exception handling
}
}
Then in the config you'd put which is safe to deploy like that, and when you need to test your custom error page you'd set it to so you can verify that it works.
Note you also need to check if HttpContext.Current is null because an exception in Application_Start will still his this method although there won't be an active context.