In the "Application-Level Configuration" section at the beginning of the chapter, we discussed the various attributes of the <trace> XML element in the web.config file. You'll recall that the requestLimit attribute sets how many page requests to keep in the trace log. So, now that you have all that data stored in the trace log, what do you do with it? Another fine question! The answer is to use the Trace Viewer to analyze it.
Accessing the Trace Viewer
The Trace Viewer is accessed via a special URL. In any directory of your web application, you can access it by navigating to trace.axd. You'll notice that there is no trace.axd file anywhere. Instead, any request for this file is intercepted by an HttpHandler that is set up in either the machine.config file or your web application's web.config file. An entry within the <httpHandlers> XML element looks like Listing 6.10.
Listing 6.10 HttpHandlers Section of the machine.config File
<httpHandlers> ...other handler entries... <add verb="*" path="trace.axd"
type="System.Web.Handlers.TraceHandler, System.Web, Version=1.0.2411.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> ...other handler entries...</httpHandlers>
With this HttpHandler entry in place, all that is left to do to use the Trace Viewer is make sure that the enabled attribute of the <trace> XML element in your web.config file is set to true.
Using the Trace Viewer
The Trace Viewer uses a fairly simple interface, consisting of two different pages. When you first navigate to the trace.axd file, you are presented with the Application Trace screen. It contains a list of page requests for which trace information has been tracked.
Three items are present in the header of this page. The first is a link to clear the current trace log. Clicking this link resets tracing, clearing all page requests from the screen. The second item in the header is the physical directory of the ASP.NET web application. The third header item is a counter that tells you how many more requests can be tracked before the requestLimit is reached. After that point, trace information is not stored for anymore page requests until the trace information is cleared by clicking the Clear Current Trace link.
The fields displayed for each page request on the Application Trace screen are No., Time of Request, File, Status Code, and Verb. In addition, a link next to each item in the list shows the details for that specific page request. Figure 6.12 shows an example of the Application Trace screen of the Trace Viewer.
Figure 6.12 Application Trace page of the Trace Viewer.
When you click one of the View Details links on the Application Trace screen, you are taken to the Request Details screen. On this page you will see is an exact representation of the trace information that would be displayed at the end of the particular ASP.NET page if tracing had been enabled on it. The only difference is the large Request Details caption at the top of the page. Several examples of this screen have been shown in previous figures in this chapter, so there is no need to present it again.