views:

54

answers:

1

I'm setting up some health monitoring for an asp .net 2.0 app.

I'd like to be able to pick up the original web request object. I'd like to be able to inspect the headers sent through and if possible any post data.

I currently have a event provider that inherits from WebEventProvider, but this does only includes the HttpWebResponse data, not the request.

How might I go about this?

+1  A: 

Do you intend to do health monitoring only for your application or all the applications in the IIS?

Only for your own application, you can create a class and derive from IHttpModule and in its Init method you can create event notification even to monitor request and any other state.

public class MyMonitor : IHttpModule
{

        public void Init(HttpApplication context)
        {
            // you can watch any of such events and respond accordingly
            context.BeginRequest += new EventHandler(context_BeginRequest);
            context.PostUpdateRequestCache += 
               new EventHandler(context_PostUpdateRequestCache);
            context.Error += new EventHandler(context_Error);
        }
        .....
}

And you can add following line in your web.config

<httpModules>
    <add name="MyMonitor" type="Namespace.MyMonitor"/>
</httpModules>
Akash Kava