Processing HTML Forms Using Internet Server Extension DLLs and Command Handlers

OverviewHow Do I

This topic describes how to use the MfcISAPICommand parameter in HTML forms.

Command Handlers

MFC's ISAPI classes for creating Internet server extension DLLs make use of "command handlers"?function names that are included in Uniform Resource Locators (URLs) and that allow a particular member function of a CHttpServer object to handle a request. Command handlers are defined with PARSE_MAP macros and are especially useful for processing HTML forms. For more information on defining command handlers, see the reference topic .

Web Browser Inconsistencies

When creating your server extension DLLs and the Web pages that contain links or forms that call your extensions, you must keep in mind that although you control what happens on the server side, you do not have control over your users' Web browsers. For example, consider the following HTML form:

<FORM ACTION="http://www.moosegrrrl.com/scripts/MyExtension.dll?MyFunction" METHOD=GET>
Enter your full name: <INPUT NAME="name" VALUE="Anonymous">
<INPUT TYPE=SUBMIT VALUE="Register">
</FORM>

This form generates a request whose syntax depends on the individual browser. Microsoft Internet Explorer 3.x will send a command line such as:

http://www.moosegrrrl.com/scripts/MyExtension.dll?MyFunction?name=Anonymous

while Netscape Navigator 3.x will send:

http://www.moosegrrrl.com/scripts/MyExtension.dll?name=Anonymous

Microsoft Internet Explorer 3.x will append a question mark to the form's action if the form is being sent to the server by way of the GET method. It will not append a question mark to the action if the form's method is POST; however, there must be a question mark after the name of the extension DLL to indicate that the DLL is a script to be run, not an item to be downloaded. Netscape Navigator 3.x will, regardless of the method used to send a form or the syntax of the ACTION, always send a command line that contains one and only one question mark at the end of the action. Other versions of these browsers and browsers written by different companies may behave differently.

Using the New MfcISAPICommand Parameter

To provide you with a simple way to get around the issue of browser inconsistencies and still retain the ability to make use of command handlers, MFC version 4.2 has implemented the MfcISAPICommand parameter. If "MfcISAPICommand" is the first available parameter, its value will be the command handler used by the CHttpServer object to process the request. If the first available parameter is not "MfcISAPICommand", then the CHttpServer object will look to the first item on the command line following the name of the extension to determine which function to call, as it does in MFC 4.1 parameter processing.

Note   Unless the "MfcISAPICommand" parameter is at the very beginning of the form data, it is processed as an ordinary parameter.

The following HTML form shows the suggested usage of the "MfcISAPICommand" parameter, which enables your Internet server extension to correctly handle requests generated by either Microsoft or Netscape browsers:

<FORM ACTION=" http://www.moosegrrrl.com/scripts/MyExtension.dll" METHOD=GET>
<INPUT TYPE=HIDDEN NAME="MfcISAPICommand" VALUE="MyFunction">
Enter your full name: <INPUT NAME="name" VALUE="Anonymous">
<INPUT TYPE=SUBMIT VALUE="Register">
</FORM>

What do you want to know more about?