I’ve been using anthem.net (an AJAX framework for .net) recently in a few projects and I’ve run into a problem handling errors on the server, that I haven’t found a good way to handle yet.

Normally in the Application_Error method in Global.asax I either log or send an email every time an error occurs, so that I’m informed immediately if someone experiences a problem.

But if an error occurs on a ajax callback, the Application_Error method is not called!

So I tried overriding the OnError-method on the page, and that went better, at least the method is called. But if I try accessing the eventargs or the Server.GetLastError() they contain no information about the exception.

So in the end I opted to encapsulate each callback method (like the button_click) in a try/catch structure that would activate the errorhandler method I wanted, if an exception was thrown.

But it’s not as good as I wanted, since I have to make sure to do this in every method I use with Anthem, and I really wanted a general solution to this.

Anyone got a better way to solve this?