views:

36

answers:

2

Hi, any idea how to retrieve the original exception thrown on server side when doing
ajax calls with jQuery and using

customErrors mode="On"

in web.config.

If mode="Off" I can take the error using this function:

error: function(xhr, status, error) {
        var error = JSON.parse(xhr.responseText); 
        alert(error.Message);
}

Thanks,
Adrian

A: 

I'm having the same problem. Does anyone knows a solution about it? Thanks

Rafael Orasmo
+1  A: 

Your best bet is to move the server method into a different host with its own web.config. If you've never done this before, ASP.NET Web Services is a good place to start.

If that's not practical, you could wrap the entire server method in a try ... catch and modify the method so that its successful return values include exception information. That has a few drawbacks: you'd have to modify the $.ajax success handler to check for errors manually, and you'd only capture exceptions that occur in the server method (but you'd miss http timeouts, DNS resolution errors, etc.).

Jeff Sternal