Understanding Tracing in ASP.NET
method of generating information about its own execution of an application is
known as Tracing. During the development of an application, it will be a normal
procedure to incorporate debugging display statements at appropriate places so
as to get the values of the dynamic variables and other outputs to trace the applications
execution cycle or path.
During tracing, by reading the output at appropriate levels the developer will be able to ascertain the flow of the logic and will be able to correct flaws in the coding or in the logical flow. In ASP.NET there are two levels of tracing services with which the developer can perform all the above-mentioned operations. The two levels of tracing are application level tracing and page level tracing and we will see few details about them here.
In classic ASP, the Response.Write is used for tracing and where as in ASP.NET you can use Trace.Write or Trace.Warn methods and you should be able to pass on two String parameters for this. In case of classic ASP, the output from the Response.Write statements will always get displayed and if you want remove the output from getting displayed then you have to physically remove all the Response.Write statements by duly scanning the entire coding.
In the case of ASP.NET, the output generated out of the Trace.Write and Trace.Warn statements will get displayed only when tracing is enabled. And for disabling or enabling the page-level tracing, you have to get the Trace attribute set in the @Page directive as:
<% @Page Trace="[True|False]" %>
Once the page-level tracing is enabled in ASP.NET then the Web page will start displaying multitude of information that may include the following:
Request Details: From this you can know the Request time, encoding type, status code, Session Id, and other details.
Trace Information: This will divulge the page level messages that have been incorporated while using Trace.Write and Trace.Warn methods.
Control Tree: A list of Web Controls on the ASP.NET Web page and all the possible relation between them will get displayed under this category.
Cookies Collection: Under this category of information, details about all the cookies will get displayed.
Headers Collection: This information pertains to the list of all HTTP headers.
Server Variables: This constitutes details about all the server variables.
All the above-mentioned information or details will get displayed only when tracing is enabled and if you want to stop the information from Trace.Write and Trace.Warn statements from getting displayed then you may have to set the tracing to false in all the individual pages.
There are few intrinsic disadvantages in page level tracing and the same was identified while using the Response.Write statements in classic ASP.NET. For instance, for enabling or disabling tracing you have to necessarily go to each and every page and set the tracing parameter either true or false depending upon the need. Further, whenever you set the tracing true for a live web site, then all the visitors who visit the web page will also be able to view the outputs of your tracing feature at the bottom of the page.
For all these problems the ASP.NET holds the answer and in ASP.NET the developers can either turn on or turn off the tracing for an entire Web application and for doing this the developer can make use of the Web.config file in which the trace setting can be defined. You can use the following parameters in trace setting:
the page-level tracing directive is not specified, then the setting specified
in the Web.config will take effect and by setting the Trace page directive to
True or False explicitly, you can override these settings on a page-level.
to our mailing list and receive new articles Note
: We never rent, trade, or sell my email lists to Visit
.NET Programming Tutorial Homepage ______________________________________________________
to our mailing list and receive new articles
: We never rent, trade, or sell my email lists to
Visit .NET Programming Tutorial Homepage