Many ASP. NET programmers may still use the Response. Write method in the background to view the value of a variable. In fact, Microsoft provides a good debugging tool, Trace. axd. Its function is mainly to configure ASP. NET code tracking service to control how to collect, store, and display tracing results.
Key options:
1. The default value of localOnly is false. This is easy to understand. If it is true, only trace information is output locally.
2. enabled: whether to enable tracking.
3. pageOutput specifies whether the Trace Output is displayed at the end of each page. If it is false, the trace output can only be accessed through the trace utility.
4. requestLimit specifies the number of Trace Requests stored on the server. The maximum is 10000. The default value is 10.
5. traceMode specifies the sequence in which trace information is displayed. SortByCategory or SortByTime (default)
For more information, see: http://msdn.microsoft.com/zh-cn/library/6915t83k%28VS.80%29.aspx
The following uses a demo to describe how to use trace. axd to debug ASP. NET.
1. Create a Web project named WebTraceTest
2. Edit the web. config file and add a trace node (on)
The content is as follows:
<trace enabled="true"
localOnly="true"
pageOutput="true"
requestLimit="15"
mostRecent="true"
/>
3. Create a page named Test. aspx. Add a text box and a button (both the control on the server side) to it and press F5 to start debugging. The following interface is displayed:
4. Enter the text in the text box and click the button. The detailed information is displayed in Form Collection, as shown below:
Using trace. axd, we can obtain the following information:
Request details: request details
Trace information: trace information
Control tree: Control tree
Session state: session state
Application State: application state
Request cookies collection: a collection of request cookies.
Response cookies collection: Response Cookie set
Headers collection: Header set
Response Headers collection: Response Header set
Form collection: a collection of forms.
Querystring collection: the querystring collection (in the URL? String Information)
Server variables: Server Variables
Note: If you only debug the current page, you only need to set the trace attribute in the header of the current. ASPX page.
Example:
<%@ Page Language="C#" Trace="true" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>