I have an override OnException(ExceptionContext filterContext) in my base controller to catch the app during any errors, and then log them. The problem I'm getting in my app is this particular method is fired off four times for certain errors. I'll walk you through a scenario:
Let's say i navigate to: http://localhost:180/someController/someAction?someId=XX
And I have poor object handling in my code. The Id passed in is an invalid one, and it retrieves some null object, I then, bc of my bad object handling, try to operate on a null object. I get an exception.
BaseController's OnException is fired off here.
That null object is still returned out to the view, where the view tries to bind it to something, or what have you.
BaseController's OnException is fired off here again, for the error in the view.
Essentially, only one error is important to me, but the trickle up effect is causing more errors to fire off, and spam my inbox :-/.
What is the correct way to catch an error in MVC2 and not have this happen to me?