Trying to figure out how to debug generic 500 errors from my .ASMX
JS:
function TestError() {
return $.ajax({
type: "POST",
url: 'Order.asmx/TestError',
contentType: "application/json; charset=utf-8"
});
}
$.when(TestError()).then(function (err) {
console.log(err);
});
C#
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public object TestError()
{
try
{
throw new Exception("Testing error");
}
catch (Exception ex)
{
return ex;
}
}
Result:

It’s not even logging the err argument. Any ideas?
Edit
adding the error to the original Ajax call is getting me logging info, but still generic & useless.
http://i42.tinypic.com/2v27fgo.jpg

Edit 2
Answered my own question and have asked a follow-up:
After a kick in the right direction and further digging I actually found this problem was twofold.
First, Dave Ward actually pointed me in the right direction in suggesting I turn off
customErrorsin the web.config. It was actually not that, but very close.The actual culprit is the Elmah error handling module. After disabling it I was able to relay custom errors regardless of whether
customErrorswasonoroff.The second issue was that although I could now handle the errors, I still couldn’t pass
System.Exceptionobjects. I discovered this is because theException.TargetSiteproperty is not serializable.I got around the problem by creating my own
JsonExceptionclass and only including the serializable properties of theSystem.Exceptionclass (abbreviated here for simplicity).And now I finally get the data I want: