Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can event handlers only be bound to HttpApplication events during IHttpModule initialization?

This is just another "working in dev server, why not working in IIS" type question.

I created a nice DAL using NHibernate as described here. When creating an ISession, I hook up an event handler to the HttpApplication.EndRequest to take care of cleaning it up.

However, I deployed my site to IIS and it says:

Event handlers can only be bound to HttpApplication events during IHttpModule initialization.

I completely understand what the message is saying, but I can't undestrand why.

I can subscribe to a Button's event in any time, why can't I subscribe to an event of the HttpApplication?

I would be very grateful if someone could shed some light on this.

And I also wonder, why is it working with the development server and not with IIS 7?

EDIT: Now that two months has passed, I still haven't received any useful answers. :(
Is this issue really that hard?

like image 508
Venemo Avatar asked May 06 '10 13:05

Venemo


1 Answers

You're trying to use the HttpApplication outside its initialization pipeline. Just don't do it. As the error says, bind your events during IHttpModule initialization.

like image 179
Mauricio Scheffer Avatar answered Nov 12 '22 07:11

Mauricio Scheffer