TAILIEUCHUNG - ASP.NET 4 Unleased - p 9

hông báo, hơn nữa, rằng Page_Load () xử lý sử dụng () để viết tin nhắn vào phần Trace Thông tin. Bạn có thể sản xuất bất kỳ chuỗi ký tự vào phần Trace Thông tin mà bạn muốn. Trong Ví dụ , giá trị hiện tại của một biến có tên hiển thị truy cập. Bạn cần phải tận dụng lợi thế của trang truy tìm khi bạn muốn xác định chính xác những gì đang xảy ra khi một trang thực thi. Bạn có thể gọi () phương thức bất cứ nơi nào bạn cần trong. | 54 CHAPTER 1 Overview of the Framework Notice furthermore that the Page_Load handler uses the method to write messages to the Trace Information section. You can output any string to the Trace Information section that you want. In Listing the current value of a variable named counter displays. You need to take advantage of page tracing when you want to determine exactly what is happening when a page executes. You can call the method wherever you need in your code. Because the Trace Information section appears even when an error exists on your page you can use tracing to diagnose the causes of any page errors. One disadvantage of page tracing is that everyone in the world gets to see your trace information. You can get around this problem by taking advantage of application-level tracing. When application-level tracing is enabled trace information appears only when you request a special page named . To enable application-level tracing you need to add the web configuration file in Listing to your application. LISTING xml version configuration trace enabled true configuration After you add the file in Listing to your application you can request the page in your browser. The last 10 page requests made after application-level tracing is enabled display. WARNING By default the page cannot be requested from a remote machine. If you need to access the page remotely you need to add a localOnly false attribute to the trace element in the web configuration file. If you click the View Details link next to any of the listed page requests you can view all the trace messages outputted by the page. Messages written with the method display by the page even when page-level tracing is disabled. From the Library of Wow eBook Installing ASPNET 55 NOTE You can use the new writeToDiagnosticsTrace attribute of the trace element to .