HttpModule Dependency Injection Timing?

Topics: Web Client Software Factory
Dec 14, 2008 at 2:24 AM
Edited Dec 14, 2008 at 2:34 AM
Hi,

Got myself in serious trouble here with WCSF in a production schedule.

I have to do interaction with forms authentication and an existing database of application users.

The only way to centralize the potentially hundreds of interactions with a custom membership provider is through a custom HttpModule. (I'm not partial to HttpHandlers.)

However, everything was fine in my module when i was using System.Web HttpContext, but then I lost the ability to find session objects when I went into a page in a folder where another web.config was controlling (standard WCSF factory generation).

So I swiched to IHttpContext contexts from Microsof.Practices.CompositeWeb.Interfaces.

And therefore I have to inject a reference to the IHttpContextLocatorService in a property injection in the HttpModule (it probably has a private or static constructor since it exposes an Init method so [CreateNew] is out.)

However, now I can't find an HttpApplication event to hook my little method in my handler to that will fire after Dependency Injection occurs.

So what am I supposed to do now?

One of the posts about HttpModule says injection occurrs in the PreRequest event. HttpApplication doesn't have an event exactly like that. PreRequest is an event of the Page (Handler?).

So I'm guessing I have to grab the reference to the WhicheverPageIsTheImportantOne.aspx handler and capture that in the HttpModules Init method. That, frankly, has some wrinkles.

And then attach my method to its OnLoad method (so its after the PreRequest event).

Am I anywhere close?

How else can I get a reference to the IHttpContextLocatorService except through an interface? Can I grab a reference to the Shell Controller and get the IHttpContextLocatorService from there? Will i run into the same injection timing issue there?

Thanks,

Kimball

Dec 14, 2008 at 5:09 AM
Well, never mind, then.

Thjis was solved by switching to SessionState in the web.config.

thanks,

Kimball