Most developers dont know about the virtual trace output page available in ASP.NET. This page allows you to see the Trace Output provided by ASP.NET. You can view many statistics about the pages that have been executed on the system.
The virtual page trace.axd is enabled by enabling tracing in your application by enabling tracing in the web.config file like this:
<trace enabled=“true” />
You can now compile and run your web page. Hit refresh a few times to get some info into the trace cache.
Visit the trace.axd file by typing it manually into your browser address bar.
For Example: http://localhost:1234/TraceExample/trace.axd
When yo view this page, you should see something similar to this:
Click on the “View Details” links and you’ll see the trace out put listed for that request. (Note: I have cut off the image because there is too much data listed to list in this post. Download the example and try it out yourself to see all the details.)
How To Write Info To The Trace
You can write information to the trace by using the Trace.Write method.
Trace.Write(“We’re writing to the trace output.”);
In the downloadable example below, I override the OnPreRender event and write info to the trace. By doing this:
protected override void OnPreRender(EventArgs e)
Trace.Write(“We’re inside of the OnPreRender Event.”);
This will write info to the trace, which can be viewed on the trace output page:
*Note: The trace.axd can only be viewed when executed on the local machine where the pages are being executed from.