HttpHandler instance and HttpApplication object - does the latter...?
Posted
by SourceC
on Stack Overflow
See other posts from Stack Overflow
or by SourceC
Published on 2009-03-31T18:51:24Z
Indexed on
2010/03/23
4:41 UTC
Read the original article
Hit count: 606
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)
{ ... }
}
© Stack Overflow or respective owner