// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using System.Web; public class RequestLoggerModule : IHttpModule { private static StreamWriter log; public void Init(HttpApplication app) { app.BeginRequest += OnBeginRequest; app.EndRequest += OnEndRequest; } protected void OnBeginRequest(object sender, EventArgs e) { log = new StreamWriter(@"C:\inetpub\wwwroot\z.z", true); HttpRequest req = ((HttpApplication)sender).Request; log.WriteLine(req.HttpMethod + " " + req.Url); foreach(string hdr in req.Headers.AllKeys) { log.WriteLine(hdr + ": " + req.Headers[hdr]); } log.WriteLine(); req.Filter = new RequestLogger(req.Filter, log); } protected void OnEndRequest(object sender, EventArgs e) { log.WriteLine(); log.WriteLine("========"); log.Close(); } public void Dispose() { } }