将捕获的ajax异常发送回服务器以执行日志记录? [英] Send catched ajax exception back to server to perform logging?
问题描述
我有一个MVC3应用程序,我正在使用Elmah将错误存储在mysql数据库中,甚至通过电子邮件发送这些错误。这是完美的工作,现在我的主要布局中有以下javascript代码:
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
});
现在,我要做的就是获取捕获的异常(ajax异常)并发回服务器使用存储Elmah异常的方法。那可能吗?如果不是我有什么选择呢?
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?
推荐答案
下面的文章显示了一些有关如何记录JavaScript错误的良好指导到Elmah:
This following article shows some good guidance on how to log JavaScript errors back to Elmah:
在ASP.NET MVC 3中使用ELMAH记录错误–第5部分–(JavaScript)
I知道向服务器报告错误的机制是MVC特有的,但是如果需要,它也应该很容易地适应ASP.NET Web窗体。
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.
这篇关于将捕获的ajax异常发送回服务器以执行日志记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!