Integrating with Internet Information Server

The principal API used to communicate with Microsoft® Internet Information Server (IIS) is Internet Server API (ISAPI). ISAPI for Windows NT can be used to write applications that users of the World Wide Web can activate by filling out an HTML form or clicking a link in an HTML page on your Web server. The remote application can then take the user-supplied information and do almost anything with it that can be programmed, and then return the results in an HTML page or post the information in a database.

ISAPI can be used to create applications that run as DLLs on your Web server. If you have used Common Gateway Interface (CGI) scripts, you will find that the ISAPI applications have much better performance because they are loaded into memory at server run time. They require less overhead because each request does not start a separate process. ISAPI extension DLLs are essentially in-process CGI applications. A client uses ISAPI extensions just as it would execute CGI applications, but instead of referencing them as "http://scripts/cgi.exe?Param1+Param2", a client would use "http://scripts/isapi.dll?Param1+Param2".

Because ISAPI applications and filters are implemented as DLLs, they are inherently single-process and can support thread pooling whereby the Internet Information Server will call out to the extension DLL. DLLs also require much less overhead for instantiation compared to a process. In addition, function calls are direct and involve no process transition or intermediate steps. Multiple extension DLLs can be loaded and called simultaneously.

    To create ISAPI extension DLLs
  1. Export and implement GetExtensionVersion. This provides the initial entry point from IIS into your extension DLL and is used to provide the version and description of your extension.
  2. Export and implement HttpExtensionProc. This is the main entry point into the functionality for your extension. It is equivalent to main( ) in a CGI application. This function is called once per request and can be called simultaneously from multiple threads. For this reason your extension DLL must be thread-safe.
  3. Use the EXTENSION_CONTROL_BLOCK data structure. This data structure contains data about the client request, and provides four callback functions that your extension DLL can use. These callback functions are:

    ReadClient, used to obtain data from the client's HTTP (Hypertext Transfer Protocol) request.

    WriteClient, used to send data to the HTTP client from a buffer.

    GetServerVariable, used to obtain information about the client connection or the server itself.

    ServerSupportFunction, which provides some general-purpose functions as well as functions that support HTTP. The basic functions include client URL redirection, return of another URL's data, and return of detailed header information.

ISAPI extension DLLs can also be combined with the Internet Database Connector to create highly interactive sites. ISAPI allows preprocessing of requests and post-processing of responses, permitting site-specific handling of HTTP requests and responses. ISAPI filters can be used for applications such as customized authentication, access, compression, encryption, logging, or client request analysis.

For more information about ISAPI, see the "Internet, Networking, and Distributed Services" section of the Microsoft Platform SDK.