Project Description

An easy-to-use and extensible ASP.NET HttpHandler-based dashboard to display customized diagnostics and statistics for a running site

Getting Started

One of the project's primary goals is ease-of-use. This is meant to be a drop-in addition to any ASP.NET website (both Web Forms and MVC).
If you are interested in using just the few diagnostics that come in the project, simply compile and drop the assembly in your bin folder, then
create a handler reference to the WebDiagnosticsHandler like so:

      <add verb="*" path="admin/diagnostics.axd" type="WebDiagnostics.WebDiagnosticsHandler, WebDiagnostics" />
Note: Due to the sensitive nature of the diagnostics information, you'll probably want to apply the proper URL Authorization

Extending The Dashboard

Another primary project goal is extensibility. That is, it may be nice that the default project comes with database connectivity checkers and
modules that list all of the currently-loaded assembly versions, however your site probably has something special that you'd like to keep an
eye on.

Adding a New Section

In order to add a new section to the dashboard, simply implement a new IDiagnostic like so:

    public class TestDiagnoser : IDiagnoser
        public Diagnosis Diagnose(HttpContextBase context)
            return new TestDiagnosis() {Timestamp = DateTime.Now };

Since IDiagnostic's return a Diagnosis (which is kinda of a server control), you'll need to create one of those, too, to define how your data is rendered.
Let's see what the TestDiagnosis looks like...

    public class TestDiagnosis : Diagnosis
        public DateTime Timestamp { get; set; }

        public override void Render(System.IO.TextWriter writer)
            var htmlWriter = new HtmlTextWriter(writer);
            htmlWriter.WriteLine("<h2>Test Diagnosis</h2>");
            htmlWriter.WriteLine("<span>Last Rendered: {0}</span>", Timestamp);
Needless to say, the Render method uses a TextWriter so you're free to render things out any way you wish.

If you execute the site after adding this Diagnoser, you might be disappointed to find that nothing gets shown on the Dashboard... First you have
to register the Diagnoser for inclusion. This can be as simple as one of two things:
  1. implement a new DiagnoserDescriptor class to define the properties for this Diagnoser
  2. add the DiagnoserDescriptorAttribute directly to the IDiagnoser class

Obviously, the second choice is the easiest - this is what you want to use when you don't need a lot of advanced configuration. Anyway, here's how you do it:

    [DiagnoserDescriptor("Test Diagnoser")]
    public class TestDiagnoser : IDiagnoser

Once you've taken either of these approaches to register a Descriptor for your Diagnoser, it will be automagically discovered and show up on the Dashboard.

Last edited Nov 8, 2010 at 3:29 AM by jesschadwick, version 3