Google/MyBrain are failing me. Without using a framework (which I'll never get past my colleagues), how do you inject a dependency into an HTTPModule given that you (the programmer) are not in control of creating the instance?
Are we into hacking up custom web.config sections + reflection or is there something cleaner I'm not seeing?
e.g. using Karl Seguin's example module as a base, and assuming the implementation of an ILogger. .Net 2.0 fwiw
public class ErrorModule : IHttpModule
{
private ILogger injectedLogger; //how to set this?
public void Init(HttpApplication application)
{
application.Error += (new EventHandler(this.application_Error));
}
public void Dispose() { /* required by IHttpModule */ }
private void application_Error(object sender, EventArgs e)
{
this.injectedLogger.doStuff(e.ExceptionObject as Exception);
}
}
It's things like this make me realise how much I despise MSDN.