A tricky problem in Web development is debugging. In ASP or simple JavaScript, developers will use the print statement to track problems in the code. As Microsoft introduces ASP.NET, this approach changes because it contains a lot of features, which can be easier to debug the web page with the TraceContext class. Selecting the scope of tracking in the ASP.NET application, you can launch the ability to track a single page or the entire web application. Web.config This file is used to launch tracking at this level. Here, I use the tracking element in the web.config file:
Track Information: Details used to display requests, including all events related to the ASP.NET page. Control Tree: The control used to display the page within the page; this includes its size and the number of related bytes saved in ViewState. Cookie Collection: list of cookies used by the page. Headers Collection: and Request-related HTTP headings, including hosts, cookie, and user-agers. Server variable: and a complete list of request related server environment variables. In the example below, I list some of the information of the tracking results. (Title Set which includes part of the tracking result.) Headers CollectionName ValueConnection Keep-AliveAccept * / * Accept-Encoding gzip, deflateAccept-Language en-usCookie ASP.NET_SessionId = vnadwr45jvrfhv55gbdygobs; LastVisited2 = 3/1/2004 2:11:35 PMHost Localhostuser-agent mozilla / 4.0 (compatible; msie 6.0; Windows NT 5.0; .NET CLR 1.1.4322) From this tracking result, you can see that the requesting client uses English and Internet Explorer 6.0, and installed .NET Framers 1.1 . Joining user information The default tracking capability is useful in many cases, but other cases may require more information on page. You can use the TraceContext class Write (write) and WARN (Warn) method to add user information to the tracking log: Write: Write information to the tracking log. WARN: Write information to the tracking log, but uses red to display information written. Each method is assumed in a variety of tasks, and most basic syntax will accept simple information and insert them into the tracking log. These methods allow you to easily put the TRACE.WRITE and TRACE.WARN statements in the needs of the needs to add user information to the tracking output. Its output is included in the tracking information section of the tracking output. (I think it can be easier to use the WARN method, because they are displayed in red.) Do not need to recompile another very good feature, after completing the tracking, you don't need to delete tracking elements; only If you need to disable tracking, this tracking statement will be ignored. When there is a problem in the product, its advantage is reflected. Once transformation is a product, you can activate the tracking of the application at this level, not to track a single page (set the PageoutPut into false), and view the tracking results through the Trace.axd page, so that users will not be disturbed . Finally, tracking features increase the burden on the application, which will affect the performance of the program. For this reason, you should only start it in the application where you need it, and it is disabled as soon as possible after the trace is completed.