views:

66

answers:

1

I pretty sure I've seen this somewhere but I can't seem to find it anywhere. I have an HttpModule that can be used across multiple requests. In other words instead of creating a new instance of the Module on every request it only ever needs to create it once. Does this ring a bell to anyone? If so, what's the method for configuring to work this way?

UPDATE I'm was actually thinking about IHttpHandler which has a property called IsReusable. HttpModules are only ever created once per application: http://www.devx.com/vb2themax/Article/19901/0/page/2

+1  A: 

I guess you could move the functionality to a static class, and call that class from your HttpModule. That way the HttpModule itself will not be kept alive, but the functionality and state that you wish to share will be.

Fredrik Mörk
that's what I was going to do, but I thought there was a way to register the module itself as a singleton
Micah
Actually, when I think about it, I think that HttpModules *are* kept alive as it is, without doing any special tricks.
Fredrik Mörk
I think I'm actually thinking about an IHttpHandler which has a property called IsReusable. I'd like to find out though more about when and how HttpModules get created and disposed of, so if you know where I can find that I would appreciate it.
Micah
I guess this is a good starting point (Walkthrough: Creating and Registering a Custom HTTP Module): http://msdn.microsoft.com/en-us/library/ms227673.aspx
Fredrik Mörk