How to Perform Debugging and Tracing in ASP.Net?

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

<compilation debug = "true">

Let's say you want to disable the debugging support, then here's the code for you

<compilation debug = "false">

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.

<asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Debug"> :

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

If you are using the Sys. Debug class, then here are the methods that will enable tracing and debugging

  • Sys.Debug.trace(message)
  • Sys.Debug.clearTrace()
  • Sys.Debug.assert(condition, message, displayCaller)
  • Sys.Debug.traceDump(object,name)

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.

<compilation debug = "true">
//usual configuration code


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 developers to give out an application suited to your business needs.

Deepa Ranganathan
  • debugging
  • tracing
  • application
By Deepa Ranganathan On 28 Aug, 15  Viewed: 542

Other blogs you may like

Upload multiple image in multiple size with progress bar in

In there is not control to select multiple files and upload them once with progress bar, so we will use a small third party DLL to achieve this functionality. We will use Flajaxian FileUploader, you can download it from [][1] We will create three different images... By Hamden   On 12 Jul 2012  Viewed: 5,690

Check/Uncheck all checkboxes in by javascript

I was searching for select/deselect all checkboxes code into a gridview. I found most of them only provide to select and deselet all the checkboxes if any of the checkbox is unselected into grid the main checkbox is not affecting. I further try to search some useful code but could not found any... By Ali Adravi   On 10 Jul 2012  Viewed: 4,301

MVC model validation for email from database in

There are many cases where we need to validate the value in controls before submitting to the database, so let's discuss email validation like format, length and existence into database. We will walk through in this article, how to validate entered user email from database, whether email is already... By Ali Adravi   On 05 Jan 2013  Viewed: 5,804

Routing with web forms application

Microsoft .NET Framework 3.5 SP1 introduced a routing engine to the ASP.NET runtime. The routing engine can decouple the URL in an incoming HTTP request from the physical Web Form that responds to the request, allowing you to build friendly URLs for your Web applications. Let's start make our... By Ali Adravi   On 05 Jan 2013  Viewed: 2,107

Log error in a text file in ASP.Net

It’s good practice to log all the error into a file or database so in future you can check, how your application is working, and is there any issue which is not caught by Q.A. team. Really it's helpful to understand and caught the issues after deploying the application on production... By Myghty   On 30 Dec 2012  Viewed: 1,089