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:
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 )?
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)
{ ... }
}
In IIS7 an application in app pool running with the integrated pipeline is always a .NET application. The code is just being defensive.
A link about HttpHander: http://msdn.microsoft.com/en-us/magazine/cc188942.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.