Extension Interaction with IIS

At the most basic level, an ISAPI extension only does one thing; it processes input from an HTTP request. The following diagram illustrates this process.

IIS receives the HTTP request from the client and determines its type. If the request is for an HTML page, the server simply formats the page and returns it to the client. If the request is for a CGI script, IIS loads the appropriate CGI EXE into a separate process space. If the request is for an ISAPI extension, as shown in the diagram, a new instance of the extension (implemented through the DLL file) is loaded into the IIS process (if the DLL is not already loaded). The new extension instance is also passed a data structure known as an Extension Control Block (ECB), which contains the input parameters specified in the HTTP request . All communication between IIS and the extension is passed through the ECB. Specific processing stages of an ISAPI extension are outlined in Extension Request Processing.

All ISAPI extensions use the dynamic linking programming model. In the Microsoft® Windows® operating system, dynamic linking provides a way for a process to call a function that is not part of its executable code. The executable code for the function is located in a dynamic-link library (DLL), which contains one or more functions that are compiled, linked, and stored separately from the processes which use them. ISAPI extensions use run-time dynamic linking. When IIS loads an ISAPI extension it uses the LoadLibraryEx and GetProcAddress functions to retrieve the starting point of the DLL functions.

ISAPI DLLs are loaded at run time by IIS and are called at the common entry points of GetExtensionVersion and HttpExtensionProc. For more information on this, see Entry Point Functions.

ISAPI extension DLLs must be multithread-safe since multiple requests will be received simultaneously. For information on how to write multithread-safe DLLs, refer to the related articles on the Microsoft Development Library compact disc, or any of the books on Win32® programming. Similarly, for information on thread-safe DLLs and the scope of usage of C run-time routines in a DLL, see the articles on sharing data in a DLL on the Microsoft Development Library disc.