on 03 October 18
Every developer checks for potential errors before launching the web application they have painstakingly developed. Two functionality, debugging and tracing, help track the error and remove all traces of the bug. In ASP.Net Ajax applications, debugging becomes a challenge as there is a good mix of client side and server side code, wherein the client side code contains scripts, styles and HTML markups.
As a developer, you will need to overcome these challenges, and offer to debug the code and remove the potential errors. Here's how you can perform both debugging and tracing for Ajax ASP.Net applications.
Methods to Enable Debugging
Let's begin by understanding the gist of debugging. It is the process of setting breakpoints along the code so that you can track the potential errors. One of the potential methods is including debug class in the Sys namespace. Of course, there are other methods too, some of which are listed below
- Enable debugging in web browser
- Integrate Visual Studio debugger to web browser you are using
- Using the Sys.Debug Class to track the errors
The methods you can adopt include one of the above mentioned three. Of course, you can also use the server side tracing method to conduct the debugging of errors. You can even trap the HTTP traffic by using external tools for this purpose.
Let's enable debugging support for your AJAX based ASP.Net application. Here's the code that you need to use
Let's say you want to disable the debugging support, then here's the code for you
Before you release the application, try to set the release version for the same. Set the ScriptMode property of the application to release the Scriptmanager controls before you deploy the app. You should also set IsDebuggingEnabled attribute in the application to true before you can begin with debugging.
How to enable debugging in the IE web browser that you are currently using? Try incorporating the below mentioned five steps to process debugging
- Go to Tools menu in the browser, and select internet as your option
- Go to advanced tab and here you need to disable script debugging checkbox
- Finally, select display notification checkbox and disable the unfriendly messages
- Sys.Debug.assert(condition, message, displayCaller)
Methods to Enable Tracing
With tracing, you can display the execution path and helps display the diagnostic information when you execute the application. You can list out the methods in the Sys.Debug class to help debug the application, trace the output and display the trace messages.
The following code is one of the many methods using which you can trace the output
If you can output the text message to the TextArea control you can use the following code
Use the ClearTrace method to clear the trace console.
//usual configuration code
Conclusion:Both debugging and tracing are internal functions built into the ASP.Net Ajax using which you can easily debug and trace the potential errors. This will help improve the pace of improvising the whole application, and deploy it faster. Hire ASP.Net Programmers to give out an application suited to your business needs.
This blog is listed under Development & Implementations Community