Debug ASP. NET with Trace. axd

Source: Internet
Author: User

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" %>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.