views:

448

answers:

1

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)?

+1  A: 
public void Init(HttpApplication app)
{
   var ssm = app.Modules["Session"] as SessionStateModule;
   ssm.Start += Foo;
   ssm.End += Bar;
}
leppie
Google brings up this solution in the comments of this blog: http://codebetter.com/blogs/karlseguin/archive/2006/06/12/146356.aspx but the author describes it as "something of a nightmare". Why would that be? Just a little concerned that this could cause issues.
cbp
Just found this answer and also wonder whether this is the right things to do, after somebosy has indicated it's "something of a nightmare"?
Mark Redman