Tracing 1www.tech.findforinfo.com. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

Download Tracing 1www.tech.findforinfo.com. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

Post on 01-Jan-2016

213 views

Category:

Documents

1 download

Embed Size (px)

TRANSCRIPT

<p>Tracing</p> <p>Tracing1www.tech.findforinfo.comContentsWhy TracingTracing in ASP.NETPage Level tracingApplication Level tracingTracing optionsTrace Output</p> <p>2www.tech.findforinfo.comDebugging in Traditional ASPONE OF THE MOST COMMON WAYS to debug traditional ASP web applications is to use trusty calls to Response.Write.This approach had several drawbacks.When you are finished debugging your web application using calls to Response.Write, you are then faced with the daunting task of stripping out all this debug code.</p> <p>3www.tech.findforinfo.comDebugging in Traditional ASPSame type of code is used both for debugging and valid out(Response.Write)When your ASP pages get to be hundreds of lines long, this can be a real pain.</p> <p>4www.tech.findforinfo.comTracing in ASP.NETTo address this issue,ASP.NET implements the TraceContext class.</p> <p>5www.tech.findforinfo.comConfiguration</p> <p>To use tracing in your ASP.NET web application, you need to enable it.This can be done at either The page level (or)The application level.</p> <p>6www.tech.findforinfo.comPage-Level Configuration</p> <p>Enabling tracing at the page level entails adding the Trace attribute to the @Page directive, like this:</p> <p>If the Trace attribute has a value of true, tracing information will be displayed at the bottom of your ASP.NET page after the entire page has been rendered.</p> <p>7www.tech.findforinfo.comApplication-Level Configuration</p> <p>Several tracing options are available at the application level.These settings are specified using the XML element in the system.web&gt; section of the web.config file.</p> <p>8www.tech.findforinfo.comExample of Application Level tracing</p> <p>9www.tech.findforinfo.comTrace Tag attributesAttributesDescriptionrequestLimitSets the no:of trace requests to store on the server,Default :10TracemodeSortByTime,SortByCategory</p> <p>PageOutputSets whether the trace information is to be displayed at the bottom of every page10www.tech.findforinfo.comTrace Tag attributesAttributesDescriptionEnabledSet when the application level tracing is enableLocalonlySet whether tracing is enabled for localhost user11www.tech.findforinfo.compage-level configuration settings overrule application-level settings.</p> <p>if tracing is disabled at the application level but is enabled at the page level, trace information will still be displayed in the browser.</p> <p>12www.tech.findforinfo.comTrace outputNow that youve heard so much about configuring ASP.NET tracing, what exactly does it provide?Essentially, the trace output generated by the TraceContext object and displayed at the bottom of your rendered ASP.NET page contains several sections.</p> <p>13www.tech.findforinfo.comRequest Details</p> <p>14www.tech.findforinfo.comRequest Details</p> <p>15www.tech.findforinfo.comTrace Information</p> <p>16www.tech.findforinfo.comTrace informationThe Trace Information section contains the various trace messages and warnings that both you and the ASP.NET engine add to the trace output.By default, the ASP.NET engine adds messages for when any events begin or end, as with PreRender.The order in which the contents of the Trace Information section appear is determined by either the TraceMode attribute</p> <p>17www.tech.findforinfo.comControl tree</p> <p>18www.tech.findforinfo.comCookies collection</p> <p>19www.tech.findforinfo.comCookies CollectionThe Cookies Collection section lists all the cookies that are associated with your ASP.NET web application.</p> <p>20www.tech.findforinfo.comHeaders collection (Http Headers)</p> <p>21www.tech.findforinfo.comForm Collection</p> <p>22www.tech.findforinfo.comForm CollectionThe Form Collection section is displayed only if your ASP.NET page includes a web form.First, it displays the pages VIEWSTATE.Below the VIEWSTATE item is a listing of each control in the Form Collection section, along with its value.</p> <p>23www.tech.findforinfo.comQuerystring collection</p> <p>24www.tech.findforinfo.comThe Querystring Collection section is displayed only if your ASP.NET page has Querystring parameters passed to it.</p> <p>25www.tech.findforinfo.comServer variable</p> <p>26www.tech.findforinfo.comFigure 6.11 Viewing a trace message with a category andexception information in the trace output.</p> <p>protected void Page_Load(object Sender, EventArgs e){int x = 1;int y = 0;try{int z = x / y;}catch(DivideByZeroException ex){Trace.Write(Errors,Testing the limits of infinity?,ex);}}</p> <p>27www.tech.findforinfo.comCustom trace messages</p> <p>28www.tech.findforinfo.com</p>