views:

26

answers:

0

Hi,

I'm using ASP.NET MVC 1.0 and have exeption handling manged by a global controller activated by the HandleException attribute on the main controller.

I've noticed that if I have an action invoked by an AJAX call, and that action fails with an internal ASP.NET error (e.g. I've tried to serialize an anonymous object) then the ASP.MVC exception filter is not fired. Therefore none of my exception handling works correctly.

Eventually the ASP.NET MVC controller is loaded but as it hasn't gone through my filter the controller is not in a state that it can report the error properly, and the exception controller itself crashes.

If I add an Application_Error to the global.asax file, then this does pick up the internal ASP.NET error, but elements of ASP.NET that I need available to forward the error to the exception controller (i.e. Session State) "is not available in this context".

Basically, I think the filter is not being fired as its not my code that is raising the error, but ASP.NET itself.

How can I trap these kind of errors and still have access to things like Session State?