Wednesday, April 6, 2011

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

From stackoverflow
  • public void Init(HttpApplication app)
    {
       var ssm = app.Modules["Session"] as SessionStateModule;
       ssm.Start += Foo;
       ssm.End += Bar;
    }
    
    cbp : 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.
    Mark Redman : 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"?

0 comments:

Post a Comment