3. Understanding Tracing
Runtime Information
Enabling Tracing
Using the Trace Object
Viewing Trace Results
Using Application-Level Trace
Demonstration: Tracing Through a Web Application
Tracing into a Component
4. Runtime Information
During runtime, you can:
Output values of variables
Assert whether a condition is met
Trace through the execution path of the application
You can collect runtime information using:
The Trace object
The Debug object
5. Enabling Tracing
Page-level tracing displays trace statements only on the configured
page
Enabling page-level tracing
<%@ Page Language="vb" Trace="true" %>
<%@ Page Language="c#" Trace="true" %>
Application-level tracing displays trace information for all pages in a
Web application
Enabling application-level tracing in the Web.config file
<trace enabled="true" pageOutput="true"
localOnly="true"/>
Practice: Check default settings
6. Using the Trace Object
Inserting trace messages
Trace.Write ("category", "message")
Trace.Warn ("category", "message")
Conditional execution with Trace.IsEnabled
If Trace.IsEnabled Then
strMsg = "Tracing is enabled!"
Trace.Write("myTrace", strMsg)
End If
if (Trace.IsEnabled)
{
strMsg = "Tracing is enabled!";
Trace.Write("myTrace", strMsg);
}
Dynamically change state of trace
Trace.IsEnabled = False
8. Using Application-Level Trace
Page Application Result
Trace=True or
Trace=True Trace results are displayed on page
Trace=False
Trace=True or
Trace=False Trace results are not displayed
Trace=False
Trace not set Trace=True Trace results are displayed on page
Application-level trace statements are displayed on
individual pages
Set pageOutput=false in the Web.config file and trace
results are viewable by trace viewer
http://server/project/trace.axd
12. How to Perform Remote Debugging
Remote debugging:
Debug Web applications remotely
Simplifies team development
Simplifies Web site management
Requirements for remote debugging:
Requires Visual Studio .NET or remote components on the
server
Visual Studio .NET must be installed on the client
Requires administrative access to the server
Requires access for the user who is performing debugging
14. Lab 6: Tracing in Microsoft ASP.NET Web
Applications
Logon Page
Login.aspx
Benefits
Coho Home Page Page Header ASPState
Winery Default.aspx Header.ascx
Menu
Registration Component
Register.aspx Class1.vb or Class1.cs Web.
tempdb
config
Life Insurance Retirement Medical Dental
Life.aspx Retirement.aspx Medical.aspx Dental.aspx
Prospectus Doctors User Control XML Web
Lab Web Prospectus.aspx Doctors.aspx namedate.ascx Service
Application dentalService1.asmx
XML
Doctors Dentists
Files