简体   繁体   中英

HttpHandler instance and HttpApplication object - does the latter…?

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:

  1. 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 )?

  2. 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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM