Share via


ISAPI: Extending Web Servers

OverviewHow Do I

This article describes some of the tasks you can perform with ISAPI Web server extensions, and how MFC supports writing them. Topics included in this article are:

  • How Does ISAPI Make it Easier to Create Internet Server Applications?

  • Advantages of Using MFC to Create Internet Server Applications

  • What Can I Do With ISAPI?

How Does ISAPI Make it Easier to Create Internet Server Applications?

You can use ISAPI to write database applications, such as an order entry system or a custom catalog. You can collect information from a user with an HTML form, and send back another HTML page customized for the user. ISAPI server extensions provide similar functionality to CGI applications. For a comparison of the two methods, see How Does ISAPI Compare with CGI?

A convenient feature of the World Wide Web is that you don't have to install your code on the client machine to run your application. This makes upgrading easy. To run an ISAPI server extension DLL, a user types a URL in a browser, for example, http://myserver/register.dll?. The DLL runs on the server and sends the HTML data back to the client.

To add an updated DLL with new features, you stop the Web server service, replace the old DLL with your new version in its shared location on the server, and restart the service. The next client request will load the latest version. This process makes it easy to add new functionality, and you upgrade only one computer instead of many.

Advantages of Using MFC to Create Internet Server Applications

Visual C++ includes the ISAPI Extension Wizard to help you create ISAPI filters and servers. This wizard is one of the choices available on the Project tab in the New dialog box, which appears when you create a new project in the development environment. For more information about establishing a new project using wizards, see Visual C++ Wizards that Help You Begin Your Program.

The ISAPI Extension Wizard makes it simple to generate a filter or a server extension. You can choose how (or if) to link to MFC; whether to have a filter, a server, or both; what filter notifications to handle at what priority; and whether the filter should get secured or unsecured notifications or both. After the project is generated, you add custom functionality and create parse maps.

Error Handling

MFC adds failure protection beyond any provided by the server. MFC handles the returning of appropriate HTTP errors to the client (for example, bad request). For a list of some common HTTP return codes, see Internet First Steps: HTTP. To handle error conditions in your program, see .

Forms Processing and Parse Maps

HTML-based forms are used to collect information from the user. This information is sent to your server via a URL that includes the name of your ISAPI DLL and a list of parameters, based on the information the user entered in the form. MFC makes parsing of these parameters easy: You write the function, declare its parameters, and use parse map macros to hook the command line arguments to your function parameters, including optional and default arguments. When a client invokes your server, MFC extracts the arguments and calls your function. MFC also returns results back to the client.

What Can I Do With ISAPI?

The following table lists some tasks you can perform using ISAPI server extensions and ISAPI filters.

I want to: Use a server extension to:
Count users of my application. Log information.
Write an order entry system. Process an HTML form that is filled out at the client and processed on the server. Consider using DB Connector, a part of Internet Information Server, for simple data processing, and ISAPI for full database access.
I want to: Use a filter to:
Count visitors to my server. Request SF_NOTIFY_LOG notification.
Do custom encryption. SF_NOTIFY_READ_RAW_DATA, SF_NOTIFY_WRITE_RAW_DATA
Do custom compression. SF_NOTIFY_READ_RAW_DATA, SF_NOTIFY_WRITE_RAW_DATA
Read raw data. SF_NOTIFY_READ_RAW_DATA
Process header information. Call GetServerVariable.
Authenticate a user. Create a filter with high priority notification request, SF_NOTIFY_AUTHENTICATION.
Log requests from a certain user, or requests containing key words. Request SF_NOTIFY_URL_MAP notification.

See Also   Internet: Where Is...