Appendix A. Debugging ASP.NET AJAX Applications

In a perfect world, every line of code we write would be flawless. There may actually be some developers out there who never make mistakes—I am not one of them. Debugging ASP.NET AJAX applications, or JavaScript applications in general, is much more difficult than finding errors in “regular” programs. An Ajax application runs on both the client and the server. This leads to some obstacles for debugging: some server errors are not shown in the client. Also, very often an error is caused by the data sent between client and server, which you need to inspect as well.

This appendix presents some useful tools that will enable you to effectively debug ASP.NET AJAX applications running in the browser (and any JavaScript code). We will also have a look at debugging features provided by ASP.NET AJAX itself.

Debugging Tools

When asked what the best way is to test JavaScript during the development process, many developers answer, “Do not use Internet Explorer.” Whereas the most recent versions of all the major browsers are really quite good, the quality of JavaScript error reporting differs greatly between them. The reporting for IE suffers the most. Take a look at the error message for identical JavaScript errors generated by different browsers. Figure A-1 shows the output in Firefox, which includes a line number, the name of the file, which caused the error, and also (when clicking on the filename) the erroneous code in question. Not great, but ...

Get Programming ASP.NET AJAX now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.