Search code examples
asp.netsessioneventshttpmodule

Attaching events to Session OnStart and OnEnd using HttpModules


Does anyone know a clean way of adding events to Session's OnStart and OnEnd events using an HttpModule (without touching the Global.asax file)?


Solution

  • public void Init(HttpApplication app)
    {
       var ssm = app.Modules["Session"] as SessionStateModule;
       ssm.Start += Foo;
       ssm.End += Bar;
    }