Learning notes: Using Trace in asp.net (trace) __.net

Source: Internet
Author: User

Learning notes: Using tracing in asp.net (trace)

Main content: What is "tracking" and why to use tracing. Turn on the trace on the page to open the track of the entire site to view trace information after opening the trace and asp.net ajax conflict how to do

First, what is "Tracking" (from MSDN)
Tracing is a way to monitor the execution of an application while it is running. When you develop. NET applications, you can add tracing and debugging instrumentation to them, and you can use this instrumentation when you develop your application and when you deploy your application. With the Trace and Debug classes, you can log information about errors and application execution to a log, text file, or other device for subsequent analysis.

Second, why use tracking.
In the era of ASP, if you need to understand the program at runtime some state, the value of variables, usually on the page using Response.Write to output the way. Most of the reasons for this are due to the weak operation of the ASP, the development environment. The result of this is that the arbitrary output on the page caused the confusion of the page, the program added to the Response.Write is also very difficult to manage, once there is any omission, it will cause unnecessary misunderstanding to the customer.
and ASP.net tracking function, not only can be in the program running every stage, tracking the state of the program and the value of the variable, in addition, it also has asp.net itself to support the various management functions. It can be displayed along with the ASPX page, or it can be rendered in a different place in a special way. As far as I know, it has the following advantages:

1, can be unified management of the entire website, can also be started on a single page. By configuring web.config, you can enable tracing for an entire Web site, or you can use it on a page.

2, does not affect the layout and rendering of the page.

3, a comprehensive reflection of the status of cookies and session, this is the first time I used tracking a reason.

4, the complete response to each page event process and execution time.

Third, open the page in the tracking

1. Adopt trace= "True" in < @page >

2. Add "trace.isenabled = True" in the code.

3, add your own tracking information:
Trace.Warn ("abc"); Warn is showing a red message.
Trace.Write ("Def"); Write shows the information of the normal color
Four, open the whole station tracking

Add in Web.config
<system.web>
<trace enabled= "true"/>
</system.web>

V. View tracking Information

1, if the page to open the tracking, then the tracking information can be directly in the page below the content of the display.

2, if the whole station tracking, you can through the "http://site name/" or "http://site name/Station call/" (VS 2005 in the new site, in the form of debugging is in the latter forms) followed by "Trace.axd" to view. For example: Http://localhost:5508/trace.axd

3, open the whole station tracking and display on the page:

<system.web>
<trace enabled= "true" pageoutput= "true"/>
</system.web>


4, open the whole station tracking and display in the Output window:

<system.web>
<trace enabled= "true" pageoutput= "false" writetodiagnosticstrace= "true"/>
</system.web>

<system.diagnostics>
<trace>
<listeners>
<add name= "Consolse" type= "System.Diagnostics.ConsoleTraceListener"/>
</listeners>
</trace>
</system.diagnostics>


Vi. How to turn on the following and asp.net ajax conflicts

Sys.WebForms.PageRequestManagerParserErrorException exception occurs when page tracking is turned on on a page that uses UpdatePanel or when full station tracking is turned on pageoutput= "true".
The reason is that page tracking has Response.Write.
The solution is to pageoutput= "false" without page tracking or full station tracking. When you need to view trace information, use Trace.axd.

Vii. Performance
The site has been tracked, so it must be low performance.
But adding some custom tracking information to the page should have a minimal impact on performance.


Appendix

1. How to: View asp.net trace information using the trace viewer

HTTP://MSDN.MICROSOFT.COM/ZH-CN/VCSHARP/WWH16C6C (vs.80). aspx

2, "Essential asp.net 2.0 chinese version" 7.11 asp.net 2.0 Tracking

Http://book.csdn.net/bookfiles/392/10039214519.shtml

3, the UpdatePanel appeared Sys.WebForms.PageRequestManagerParserErrorException abnormal

Microsoft JScript run-time Error: Sys.WebForms.PageRequestManagerParserErrorException: Unable to parse messages received from the server. This error is common because the response filter, HttpModule, or server trace is enabled when the response is modified by calling Response.Write (). Further information: An error occurred while parsing the "Xxx|xxx|xxx" near.


Http://www.cnblogs.com/simplenl/archive/2008/08/12/1266120.html


The article mentions the various reasons for the exception, one of which is that the trace on the Web page is opened


4. MSDN: "Tracking applications and inserting detections in applications" ASP.net tracking overview

Ms-help://ms. Msdnqtr.v90.chs/dv_fxdebug/html/773b6fc4-9013-4322-b728-5dec7a72e743.htm

Ms-help://ms. Msdnqtr.v90.chs/dv_vwdcon/html/1552561d-887c-4002-8770-f92662cdf416.htm#readingtraceinformation

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.