ISAPI Extentions and Filters


When to Use ISAPI Extensions

ISAPI extensions are best used in situations where you need to integrate a C or C++ library with your web application, or need to have specific, lower-level control over your application. For instance, you may need to integrate a proprietary database engine. Although in this case you could use native DLL calls from a .NET application, the amount of work to integrate the two could well be massive. An ISAPI extension is much like a CGI application (an executable that is similar to a script, and returns an HTML page), but with important differences. The most significant difference is that ISAPI extensions reside in IIS’s memory space, meaning a new process does not have to be created for every request. This by itself makes them far more scalable than CGI applications.

When to Use ISAPI Filters

ISAPI filters intercept a request at various stages as it moves through the pipeline. Filters are server-wide or site-wide, although they can be made to be applied only to certain requests. ISAPI filters were, for a long time, the only way to provide this functionality. Now ASP.NET HTTP modules, which reside completely inside the ASP.NET pipeline and are separate from IIS, provide a filter-like ability for ASP.NET pages.

Overview

Every ISAPI Extension is contained in a separate DLL written as Internet Web Server applications are required to export two entry points: GetExtensionVersion and HttpExtensionProc (TerminateExtension is optional).

Every ISAPI filter is contained in a separate DLL with two common entry points: GetFilterVersion and HttpFilterProc. When the DLL is loaded, GetFilterVersion is called. This lets the filter know the version of the server and also lets the filter tell the server the filter version and the events that the filter is interested in.

ISAPI is an API that allows developers to extend the IIS web server by plugging in native DLLs, written usually in C or C++ (although it's quite possible to write extensions in other languages that support compiling to native code and can import a C API, such as Delphi).

ISAPI actually plays two very separate roles in interaction with the web server. ISAPI extensions provide a way for native code to be executed to return a page (similar to an ASP script, for example).

ISAPI filters on the other hand deal with the request itself, as it moves through IIS, and can intercept and manipulate a request at many different stages in its lifetime.

ISAPI Filters are comparable to Apache modules, if you are familiar with the Apache web server.


Links:

ISAPI Programming - http://msdn2.microsoft.com/en-us/library/at50e70y(VS.80).aspx

ISAP Extensions and Filters - http://microsoft.apress.com/asptodayarchive/73978/isapi-extensions-and-filters

Developing ISAPI Extensions and Filters -
http://pcdoc.bibliothek.uni-halle.de/web-kurs/api/isapimrg.htm

ISAPI - http://www.microsoft.com/msj/0498/iis/iis.aspx

ISAPI Extensions - http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/iisbook/c06_isapi_extensions_and_filters.mspx?mfr=true