开发者

Logging JQuery script errors to ASP.NET server via PageMethods & AJAX Calls

I'm working 开发者_如何学Pythonon a website that uses JQuery on the client and ASP.NET/C# and PageMethods on the server.

I'm looking for some suggestions for logging JavaScript errors on the server.

My plan is to have some general-purpose PageMethods in my base page, and if an error occurs in a try/catch block in my JQuery code, I'll call the PageMethod and pass up the function name, user context, and other relevant params (like JSON strings, variables, etc).

Obviously, I'll only be able to do this for errors that are caught in a try/catch block.

A similar question was posed here but that was more than 6 months ago.

I'm considering both Log4Net and native .NET logging capabilities on the server.


I am not a big fan of using log4net and other tools when you can do it using simple methods like an async call to the server.

what I would suggest is you create a handler to handle all your errors in JS and make an async call to it using jquery.ajax () (http://api.jquery.com/jQuery.ajax/) and at the server you handle these errors and handle it with your error logger on server.

Does that sound good?

You should avoid learning new tools and adding to the complication cos if suddenly there are any errors you are now dependent on the support for that tool.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜