4

I've been looking for a way to log unhandled exceptions that occur in asp.net static page methods (which are called via javascript from the browser).

This question led me to setup ELMAH but unfortunately I'm back at square one because it doesn't catch these exceptions. (it is working perfectly for exceptions during regular page cycle however).

I've tried adding the MsAjaxDeltaErrorLog http module but this has no effect (I'm using .NET 3.5 anyway).

Is it actually possible for these errors to be logged without wrapping every single method in a try / catch?

Community
  • 1
  • 1

1 Answers1

2

Web Method errors aren't processed by global asax's error event. You have to log them manually,

try 
{
    some web method code 
}
catch(Exception ex)
{
    Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
}

ref: How to use ELMAH to manually log errors?

Community
  • 1
  • 1
MatthewMartin
  • 32,326
  • 33
  • 105
  • 164