Tải bản đầy đủ (.pdf) (20 trang)

Module 5: Using Trace in ASP.NET Pages

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (789.46 KB, 20 trang )








Contents
Overview 1
Overview of Tracing 2
Trace Information 3
Page-Level Trace 4
Application-Level Trace 9
Lab 5: Adding Trace to an ASP.NET Page 14
Review 15

Module 5: Using Trace
in ASP.NET Pages
BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY

Information in this document is subject to change without notice. The names of companies,
products, people, characters, and/or data mentioned herein are fictitious and are in no way intended
to represent any real individual, company, product, or event, unless otherwise noted. Complying
with all applicable copyright laws is the responsibility of the user. No part of this document may
be reproduced or transmitted in any form or by any means, electronic or mechanical, for any
purpose, without the express written permission of Microsoft Corporation. If, however, your only
means of access is electronic, permission to print one copy is hereby granted.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual
property rights covering subject matter in this document. Except as expressly provided in any
written license agreement from Microsoft, the furnishing of this document does not give you any


license to these patents, trademarks, copyrights, or other intellectual property.

 2001 Microsoft Corporation. All rights reserved.

Microsoft, BackOffice, MS-DOS, Windows, Windows NT, <plus other appropriate product
names or titles. The publications specialist replaces this example list with the list of trademarks
provided by the copy editor. Microsoft is listed first, followed by all other Microsoft trademarks
in alphabetical order. > are either registered trademarks or trademarks of Microsoft Corporation
in the U.S.A. and/or other countries.

<The publications specialist inserts mention of specific, contractually obligated to, third-party
trademarks, provided by the copy editor>

Other product and company names mentioned herein may be the trademarks of their respective
owners.


Module 5: Using Trace in ASP.NET Pages iii

BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY

Instructor Notes
This module describes the trace feature of ASP.NET. Students will learn about
the two tracing techniques in ASP.NET, page-level tracing and application-
level tracing.
In the lab, students will enable and disable tracing for an ASP.NET page. They
will also add custom trace messages to an ASP.NET page and a middle-tier
component.
After completing this module, students will be able to:
Describe page-level and application-level tracing.

Enable and disable tracing for an ASP.NET page.
Add custom trace information.

Materials and Preparation
This section provides the materials and preparation tasks that you need to teach
this module.
Required Materials
To teach this module, you need the following materials:
!
Microsoft
®
PowerPoint
®
file 2063A_05.ppt
!
Module 5, “Using Trace in ASP.NET Pages” (2063A_05.doc)
!
Lab, “Adding trace to an ASP.NET Page” (2063A_L05.doc)

Preparation Tasks
To prepare for this module, you should:
!
Read all of the materials for this module.
!
Complete all the demonstrations.
!
Complete the lab.

Presentation:
60 Minutes


Lab:
30 Minutes
iv Module 5: Using Trace in ASP.NET Pages

BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY

Module Strategy
Use the following strategy to present this module:
!
Overview of Tracing
Start the module with an overview of tracing and why do we need to enable
trace on an application page.
!
Trace Information
This section described the type of information that can be retrieved by
enabling trace on a page. When teaching this, point to each category in the
illustration and discuss it briefly.
!
Page-Level Trace
Page-level Tracing provides the ability to write debugging statements
directly to the output of a page, and conditionally execute debugging code
when tracing is enabled. This section describes how page-level tracing
works. This section ends with a topic on how to trace into a component.
When talking about tracing into a component, tell them about why it is
useful to be able to trace into a component.
!
Application-Level Trace
ASP.NET also provides a way to enable tracing for the entire application
and not just a single page. This section describes how application-level trace

works.

Module 5: Using Trace in ASP.NET Pages 1

BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY

Overview
!
Overview of Tracing
!
Trace Information
!
Page-Level Trace
!
Application-Level Trace


In earlier versions of ASP, tracing of code was accomplished by inserting
Response.Write statements, wherever required. One main drawback of this
technique was the removal of the excess code added when the application is
deployed, and thus the inability to use the output from the Response.Write
statements in a production environment. ASP.NET overcomes such drawbacks
by introducing an automatic tracing mechanism. This tracing mechanism can be
enabled and disabled either on a page-by-page basis, or for an entire
application, and can be configured in the config.web file.
After completing this module, you will be able to:
!
Describe page-level and application-level tracing.
!
Enable and disable tracing for an ASP.NET page.

!
Add custom trace information.

<<add something on Debug object and conditional compilation. Trace is good
because you can turn it on from config.web in a production environment to see
what's going wrong. It can also output to a log file in a production
environment>>
Topic Objective
To provide an overview of
the module topics and
objectives.
Lead-in
In this module, you will learn
how to use the trace feature
of ASP.NET.
2 Module 5: Using Trace in ASP.NET Pages

BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY

Overview of Tracing
!
With Tracing You Can:
#
Output Variables or Structures
#
Assert Whether a Condition is Met
#
Trace through the Execution Path of the Application
!
Can Be Enabled and Disabled, Either on a Page-By-Page

Basis, or for an Entire Application


The tracing feature enables you to insert debugging print statements into your
code to output variables or structures, assert whether a condition is met, or just
generally trace through the execution path of the application.
All this information is outputted with a page or saved to a log.
Topic Objective
To describe tracing.
Lead-in
Tracing enables you to see
the execution path and
output variable values from
your application.
Module 5: Using Trace in ASP.NET Pages 3

BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY

Trace Information


Tracing provides a lot of information to the developer of an ASP.NET
application. The trace output screen contains the following categories of
information.
Category Description

Request Details Information about the request: session ID, time of request, type
of request, and the status.
Trace Information Output from standard and custom trace statements.
Control Tree List of all items on the page

Cookies Collection List of Cookies being used.
Headers Collection List of items in the HTTP header.
Form Collection List of controls and their values on the form being posted.
Server Variables List of all server variables and their values.

Topic Objective
To list the information
provided in a trace output.
Lead-in
The trace output page
provides lots of information.
4 Module 5: Using Trace in ASP.NET Pages

BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY

$

Page-Level Trace
!
How Does Page-Level Trace Work?
!
Demonstration: Adding Page-Level Trace Statements
!
Tracing into a Component


Page-level tracing provides the ability to write debugging statements directly to
the output of a page, and conditionally execute debugging code when tracing is
enabled. The performance data and the developer-specified messages (if any)
are injected into the HTML output stream to the client to help clarify precisely

what occurs when the framework processes a page request.
In this section, you will learn how page-level tracing works.
Topic Objective
To describe how page-level
tracing works.
Lead-in
ASP.NET aids the
debugging and testing
process by providing two
types of trace capabilities,
page-level and application-
level.

×