140 likes | 284 Views
Module 6: Tracing in Microsoft ASP.NET Web Applications. Overview. Understanding Tracing Remote Debugging. Understanding Tracing. Runtime Information Enabling Tracing Using the Trace Object Viewing Trace Results Using Application-Level Trace
E N D
Overview • Understanding Tracing • Remote Debugging
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
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
Enabling Tracing • Page-level tracing displays trace statements only on the configured page • Enabling page-level tracing • Application-level tracing displays trace information for all pages in a Web application • Enabling application-level tracing in the Web.config file • Practice: Check default settings <%@ Page Language="vb" Trace="true" %> <%@ Page Language="c#" Trace="true" %> <trace enabled="true" pageOutput="true" localOnly="true"/>
Using the Trace Object • Inserting trace messages • Conditional execution with Trace.IsEnabled • Dynamically change state of trace Trace.Write ("category", "message") Trace.Warn ("category", "message") 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); } Trace.IsEnabled = False
Page Application Result Trace=True Trace=True or Trace=False • Trace results are displayed on page Trace=False Trace=True or Trace=False • Trace results are not displayed Trace not set Trace=True • Trace results are displayed on page Using Application-Level Trace • 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
Demonstration: Tracing Through a Web Application • Page-level tracing • Application-level tracing
Tracing into a Component • Import the System.Web Library • Enable Tracing • Call Trace methods Imports System.Web using System.Web; HttpContext.Current.Trace.IsEnabled = True HttpContext.Current.Trace.IsEnabled = true; HttpContext.Current.Trace.Write _ ("component", "this is my trace statement") HttpContext.Current.Trace.Write ("component", "this is my trace statement");
Lesson: Remote Debugging • How to Perform Remote Debugging
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
Review • Understanding Tracing • Remote Debugging
Lab 6: Tracing in Microsoft ASP.NET Web Applications Logon Page Login.aspx BenefitsHome PageDefault.aspx CohoWinery Page HeaderHeader.ascx ASPState Menu ComponentClass1.vb or Class1.cs Registration Register.aspx Web.config tempdb Life InsuranceLife.aspx RetirementRetirement.aspx MedicalMedical.aspx DentalDental.aspx XML Web ServicedentalService1.asmx ProspectusProspectus.aspx DoctorsDoctors.aspx User Controlnamedate.ascx Lab Web Application XML Files Doctors Dentists