HttpHandler instance and HttpApplication object - does the latter...?
- by SourceC
A Book showed an example where ( when using IIS7 ) the following module was configured such that it would be used by any web application ( even by non-asp.net apps ) running on a web site. But:
A) if this module is invoked for non-asp.net application, then how or why would HttpApplication object still be created, since non-asp.net apps don’t run in the context of CLR ( and thus Asp.Net runtime also won’t run )?
b) Assuming HttpApplication object is also created for non-asp.net apps, why then does the code inside Init() event handler have to check for whether HttpApplication object actually exists? Why wouldn’t it exist? Isn’t this HttpApplication object which actually instantiates Http module instance?
Here is Http handler:
public class SimpleSqlLogging : IHttpModule
{
private HttpApplication _CurrentApplication;
public void Dispose()
{
_CurrentApplication = null;
}
public void Init(HttpApplication context)
{
// Attach to the incoming request event
_CurrentApplication = context;
if (context != null)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
}
}
void context_BeginRequest(object sender, EventArgs e)
{ ... }
}