← All articles
development

The hidden Trace page, trace.axd

ASP.NET's built-in trace.axd page shows detailed per-request timing and stats once you flip on tracing in web.config, plus how to log custom output.

Donn Felker

Donn Felker

2007.02.13 · 1 min read · updated July 5, 2013

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:

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.”);
base.OnPreRender(e);
}

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.

Download Example

TraceExample.zip (1.77 KB)

Donn Felker

Written by Donn Felker

I've spent 25+ years shipping software, writing books, and running my own companies. I write about thinking clearly, working for yourself, and doing real work while AI rewrites the rules. New essays land here every week.

Get the newsletter

Keep reading