I am trying to implement Error handling using Action Filters Attributes as per ScottGu's blog
My code is as follows:
[HandleError]
[HandleError(ExceptionType = typeof(NullReferenceException), View = "CustomError")]
public class ArticlesController : Controller
{
public object OhDearACrash()
{
throw new Exception("Oh Dear");
}
public object NullRefCrash()
{
throw new NullReferenceException();
}
I am encountering an issue where I am never able to hit the CustomError view as I receive an exception when the exception is thrown
OhDearACrash: Exception was unhandled by user code
NullRefCrash: NullReferenceException was unhandled by user code
and so the unhandled exception is picked up by the Default [HandleError] which routes to View/Shared/Error.aspx which handles the error.
How do I handle the unhandled exception?