🇵🇸 Call for a #CeasefireNOW 🇵🇸

Act Now

HttpApplication EndRequest Event Invoked Many Times In Single Request?

The other day I was putting the last touch of a temporary way to manage the NHibernate session (ISession) in Bunian. So part of the task was to bind a method to the HttpApplication EndRequest event (in the Global.asax.cs file) like the following: public override void Init() { this.EndRequest += WorkContext.NHibernateSessionManager.Instance.HttpRequestEnded; } By doing this, at the end of each page request the NHibernateSessionManager.Instance.HttpRequestEnded() will be called and I can clean the session then. But to my surprise this method was called at least 10 times!! So I thought maybe the Global.Init() method is called many times for some reason and I ended up binding the same method to the EndRequest event many times, so I set a breakpoint at the Global.Init() method and…it’s called one time only. ...

December 14, 2008 Â· Emad Alashi