Deploying HTTP Handlers and HTTP Modules
Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1
ASP.NET provides IHttpHandler and IHttpModule interfaces that allow you to use APIs that are as powerful as the Internet Server API (ISAPI) programming interfaces available with IIS but with a simpler programming model. HTTP handler objects are functionally similar to IIS ISAPI extensions, and HTTP module objects are functionally similar to IIS ISAPI filters.
ASP.NET maps HTTP requests to HTTP handlers. Each HTTP handler enables processing of individual HTTP URLs or groups of URL extensions within an application. HTTP handlers have the same functionality as ISAPI extensions with a much simpler programming model.
An HTTP module is an assembly that handles events. ASP.NET includes a set of HTTP modules that can be used by your application. For example, the SessionStateModule is provided by ASP.NET to supply session-state services to an application. You can also create custom HTTP modules to respond to either ASP.NET events or user events.
Procedures
To compile, deploy, and register HTTP handlers
Compile and deploy the .NET class for the HTTP handler in the \Bin directory under the application's virtual root. For more information, see Deploying Local Application Components.
Register the HTTP handler, synchronous or asynchronous, in the application's Web.config configuration file. The following example maps all HTTP requests to the classes MyHandler.New and MyHandler.Fin in the assembly MyHandler that is in the file MyHandler.dll.
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="MyHandler.New"
type="MyHandler.New, MyHandlerAssembly" />
<add verb="*" path="*.myNewFileExtension"
type="MyHandler.Fin, MyHandlerAssembly" />
</httpHandlers>
<system.web>
</configuration>
The <add> elements within the <httpHandlers> configuration section have three attributes: path, type, and verb. For more information, see <add> Element for <httpHandlers>.
Register the HTTP handler extension as a script map in IIS. For more information, see Setting Application Mappings in IIS 6.0.
To compile, register, and deploy HTTP modules
Compile and deploy the .NET class for the HTTP module in the \Bin directory under the application's virtual root. For more information, see Deploying Local Application Components.
Register the HTTP module in the application's Web.config configuration file. The following example registers an OutputCache module to an application.
<configuration>
<system.web>
<httpModules>
<add name="OutputCache"
type="System.Web.Caching.OutputCacheModule, System.Web,
Version=1.0.2800.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"/>
</httpModules>
<system.web>
</configuration>
For more information about working with and registering HTTP handlers and HTTP modules, see information about HTTP handlers or HTTP modules in the MSDN Library.