..
The architecture and programming techniques have made modern software development much more standardized and controllable than ever before, thanks to libraries such as ASP.NET and Windows Forms, however inevitable in some cases, the applications do not behave as expected and in such situations becomes important to find its causes.
The starting point for diagnosis and debugging of applications is called ASP.NET page tracing system. The Page class has a property called Trace, and when it is set to true indicates the execution environment to include an account of the entire context of requests and responses at the end of the HTM code sent to the client

Recall that a page consists of a number of controls in a sort of hierarchy. An instance of the Page class includes various checks and controls themselves can incorporate other controls. The trace includes a section page where you can see the page composition in terms of server side controls.
If one of our application form on a web enabled tracing in the page. Aspx file will find its reference in the Page directive

If we start the application we will see tracing information about the page at the end of the HTML stream

Going down the page we can display the hierarchical tree of controls contained in it

Further down you can then see some information associated with the request as a session state, application state, the server-side variables, etc.. Obviously it is not immediately understand the usefulness of such information, but when you find yourself having to identify specific problems within a web application more complex then they could be very useful.
I wanted to point out that among the various information included in the HTML stream, there are also references to the individual instructions executed it inside the page. If you load in the event of web form that we used in our previous example we write something like
protected void Page_Load (object sender, EventArgs e)
{
Trace.Warn ("Page_Load", "Test annotation called");
}
launching the application again here is what we will see

Using the method Trace.Warn So you can enter certain indicators within our code to identify potential problems.
Although the tracing of a single page is very useful it has the drawback of filling the page even after all unnecessary information. To work around this problem you can apply application-level tracing (tracing application), which allows to obtain the same information as the page level but they are placed in memory and made available through a separate page.
To enable tracing application must modify the web.config file of our application as follows
<configuration> <system.web> <trace enabled="true"/> </ System.web> </ Configuration>
Done this if we start at the application and add the corresponding suffix Trace.axd here is what we will see

ie the same information seen before but on a separate page.
Summing up, therefore, the tracing is a very useful tool for debugging our applications, but especially when they are already deployed. When it is instead being developed to put messages to be traced and then run the applications and see what happens probably is not the most efficient way to debug.
Visual Studio provides an excellent debugging support, and you can use the tools provided by the environment to analyze the code of our applications at run line by line.
To enable debugging of our application requires that the ASP.NET web.config file contains the following directive
<configuration> <system.web> <Compilation debug = "true" targetFramework = "4.0" /> </ System.web> </ Configuration>
At this point we can place a breakpoint in several points of our code we want to analyze and start the application by pressing F5. We will see that when running the code arrives at a breakpoint, it will stop, allowing us to step through code line by line by clicking the F10 key. The line of code that runs is highlighted in yellow

Clicking on the F11 at a method to analyze the code will pass the method in question. During the stop debugging when the mouse pointer on a variable we are shown its value

Other useful tools for debugging are the windows: Locals, Watch, CallStack threads and to deepen the functionality of which I refer you to the Microsoft official documentation.
Debugging is closely related to error handling and to deepen this subject I refer you to an article previously written by me that you can find here .
| |
ASP (Advanced)
Full course for creating dynamic Web sites. From 39 €. |
| |
ASP.NET (Course)
Full course for building Web applications from 49 €. |
| |
SQL and Database (Course)
Create and manage relational databases. From 39 €. |