问题
i have an MVC3 application and i'm using Elmah to store the errors in a mysql database and even send those errors by email. This is working perfectly, now i have this javascript code in my main layout:
$(document).ajaxError(function (e, xhr, settings, exception) {
//SEND BACK TO SERVER THE EXCEPTION
});
Now, what i want to do is to get the catched exception (the ajax exception) and send back to server to a method that stores that exception with Elmah. Is that possible? If it isn't what choice do i have?
回答1:
This following article shows some good guidance on how to log JavaScript errors back to Elmah:
Logging Errors with ELMAH in ASP.NET MVC 3 – Part 5 – (JavaScript)
I know the mechanism to report the error to the server is specific to MVC, but it should be easily adaptable to ASP.NET Web Forms as well if needed.
来源:https://stackoverflow.com/questions/16530358/send-catched-ajax-exception-back-to-server-to-perform-logging