Sunday, January 8, 2012

Implementing an HttpModule ASP

The second method of extending the pipeline is to implement an HttpModule. Modules are
Microsoft’s intentional design for reusing pre- and post-processors across IIS applications.
The last technique you looked at (that of inheriting from HttpApplication in a standalone
assembly and reusing across IIS applications) has a serious limitation that modules don’t
have: You can only use one class per application (even though you can reuse that same class
across several applications).
HttpModules are designed so that several can be plugged into a single IIS application. The
extensions that Microsoft adds to the pipeline that you examined previously are implemented
as HttpModules. So by default, any IIS application has about a dozen modules plugged in and
extending the pipeline.
Modules are designed to be “plugged into” the pipeline using the web.configfile. You can
add a module to all IIS applications by adding it to the web.configat the root of a web server,
or you can add modules to specific applications by adding them to the web.configat the
virtual root of an application.
Under the system.webelement of the web.configis an HttpModules element. Any number
of modules can be added using child Add elements under the HttpModules element. Here’s a
configuration snippet that adds the module SomeModule
Running Codes



No comments:

Post a Comment