Server Variables

Overview

This example demonstrates how to access and display server variables using an ISAPI extension. Once compiled and registered, a client browser that accesses the DLL will receive all documented IIS server variables and values.

Code Tour

The sample implements the standard ISAPI entry-point function GetExtensionVersion to identify itself to the server. The real meat of the processing, as usual, however, occurs in the other entry-point function, HttpExtensionProc. This function begins, after it establishes a data array of available server variable names, by sending the HSE_REQ_SEND_RESPONSE_HEADER_EX extension request to the server, along with the content type of text/html and two \r\n pairs. The server will send a complete HTTP response header to the client browser, and the connection is now open for whatever the extension would like to write.

The rest of the sample is a large loop that iterates through the data array of server variables, searching for each variable name and value using the server call-back function GetServerVariable. Each server variable is printed, along with the value of the variable. Error checking is accomplished after each GetServerVariable with a GetLastError call, to make sure that there were no problems retrieving the server variable. After all of the server variables have been displayed, the extension exits and the connection is terminated.

Location

This project is available in the ...\isapi\extensions\servervariables subdirectory of the IIS samples directory.