views:

501

answers:

3

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)
  { ... }
}



+1  A: 

In IIS7 an application in app pool running with the integrated pipeline is always a .NET application. The code is just being defensive.

AnthonyWJones
A: 

Hello,

In IIS7 an application in app pool running with the integrated pipeline is always a .NET application.

So even if application in application pool is running in Java environment, this Java environment will somehow run on top of Net?


The code is just being defensive.

But if Http handler instance is created by HttpApplication object, then checking if HttpApplication object exists is pointless, since it must exist, else Http handler wouldn’t be created in the first place?


Much appreciated

SourceC
A: 

A link about HttpHander : http://msdn.microsoft.com/en-us/magazine/cc188942.aspx

Nguyen Viet Hien