Google analytics script

Latest jQuery CDN with code tiggling.

Showing posts with label IHttpModule. Show all posts
Showing posts with label IHttpModule. Show all posts

Sunday, 23 January 2011

How to correctly use IHttpModule to handle Application_OnStart event

In one of my previous blog posts (Writing a custom IHttpModule that handles Application_OnStart event) I've been talking about using IHttpModule to also handle application start event which is a non-documented feature. Sure it works, but you may see some strange behaviour of duplicated (or even multiplicated) functionality being executed. You probably won't see this with your applications in development, because your local IIS isn't really heavy duty workhorse, but in production environment you may see this strange behaviour. Investigating it is even a bit more complicated because of the running application serving live traffic. Let me help you. So I will point you in the right direction and more importantly show you a solution that makes things work reliably even on a heavy load IIS.

Wednesday, 18 August 2010

Writing a custom IHttpModule that handles Application_OnStart event

If you've been developing Asp.net web applications you've probably come across the IHttpModule interface, that makes it possible to write reusable request-level event handlers. The same thing can of course be done by writing event handlers inside the Global.asax codebehind, but then you wouldn't be able to reuse the same code unless you do a copy/paste.

But Global.asax codebehind has one particular advantage over your custom modules: it can also attach to application-level events like application start event for instance. As per documentation, this is not possible with a custom module. Or so I thought...