INFO: Troubleshooting Windows CGI Applications with IISLast reviewed: May 20, 1997Article ID: Q151094 |
The information in this article applies to:
SUMMARYNOTE: The following acronyms are used within this article: - Internet Information Server (IIS) - Common Gateway Interface (CGI) - Internet Server Application Programming Interface (ISAPI) - Dynamic Link Library (DLL) - Software Development Kit (SDK) - World Wide Web (WWW) Below is a description of three common server extension technologies.
ISAPI ExtensionsISAPI server extensions are implemented as DLL files. A small set of functions allow the DLL to communicate with the WWW server. The DLL actually becomes part of the WWW server. ISAPI extensions are by far the fastest. Because function pointers are used to communicate with the server, languages that cannot accommodate function pointers cannot be used (for example, Microsoft Visual Basic).
CGI ApplicationsCGI server extensions are implemented as console applications. Input and output are communicated with normal standard input, standard output, and environment variables. CGI EXEs run in their own process space, and one process is created per request. Some languages do not support standard input, standard output, and/or environment variables.
Windows CGI ApplicationsWindows CGI server extensions are implemented as Windows-based GUI applications. INI files (profiles) and temporary files are used to communicate input and output. For each request, an INI file is created, along with all necessary temporary files. Output is written to a pre- designated temporary file. While writing a Microsoft Visual Basic application conformant with Windows CGI is easy, the interface is dependent on files and is inherently slow. IIS directly supports two types of server extensions: CGI executables and ISAPI DLLs. All other interfaces are supported through either CGI or ISAPI. Specifically, IIS supports Windows CGI executables (usually written with Microsoft Visual Basic) through the use of an ISAPI DLL. Windows CGI support is available via the IS2WCGI sample provided in the Win32 SDK. Is2wcgi.dll, an ISAPI application, translates the ISAPI environment into the Windows CGI environment. This article provides tips on running existing Windows CGI applications with IS2WCGI. NOTE: The Windows CGI specification is totally different than the CGI specification. Do not confuse the two.
MORE INFORMATIONWindows CGI applications are Windows-based executables, commonly written with Microsoft Visual Basic. The Windows CGI spec (authored by Robert B. Denny) first appeared in the O'Reilly Website product. In order to translate ISAPI into Windows CGI, IS2WCGI does the following three things:
TEST 1: Does Is2wcgi.dll work with Is2wcgi.exe on your computer? The first step to determining the problem is to make sure the DLL is functional using the sample Windows CGI executable provided. Is2wcgi.dll and Is2wcgi.exe must be in the same directory, and they are copied to C:\Inetsrv\Scripts\Sdk by the Win32 SDK makefiles.
After you complete step 6, you should get a reply back from the server reflecting the profile created by the Is2wcgi dll. If this works, go to Test 6 below. TEST 2: Upon receiving a reply, is the browser asking you to save something?This is one of the most common problems. If read access is set on the directory containing Is2wcgi.dll, the server will send the DLL instead of running it. See Test 1. TEST 3: Is the IUSR_Guest and SYSTEM account set up properly? IIS creates a guest account for anonymous web accesses during installation. Verify that an account similar to IUSR_YourMachineName has read, write, create, delete, and execute permission in the directory containing Is2wcgi.dll. Remember that the DLL creates temporary files, runs the Windows CGI application, and deletes the files after it is done. Also, remember that the IUSR account is part of the Guest group and inherits guest restrictions. Is2wcgi.dlls HttpExtensionProc function will run in the IUSR_Guest account, and the Windows CGI application will run in the local system account. Any permissions granted to IUSR_Guest should also be granted to the local system account. If you discovered that IUSR_Guest or the local system account did not have appropriate access, modify access, restart the WWW service, and go back to Test 1. TEST 4: Are all necessary DLLs available on your NT server? Do they have appropriate permissions?Is2wcgi.dll may be dependent on the C runtime DLLs, unless you statically link in the C runtimes during the build. Do the following to make sure all runtime DLLs are available:
TEST 5: Was the DLL ever loaded? At this point, something was missed. Verify that IIS loaded the DLL by copying over it or deleting it. When IIS is running and has Is2wcgi.dll loaded, you will not be able to copy over it or delete it. If Is2wcgi.dll was not ever loaded, start over and conduct careful troubleshooting. If it is loaded, see other techniques below for more ideas on how to troubleshoot. TEST 6: Try Is2wcgi.dll with your form. Use Is2wcgi.exe as a diagnostic tool for your form. Modify the ACTION attribute in your HTML form so Is2wcgi.dll is executed. For example, the FORM tag should look similar to the following:
<FORM ACTION="http:/Scripts/SDK/IS2WCGI.DLL" METHOD=POST>Reload your HTML page on the browser and submit data to IIS. The reply will reflect the Windows CGI profile (.INI file) created for your page. TEST 7: Try your own Windows CGI app. With Is2wcgi.exe working, you are ready to try your own Windows CGI application. If your sample name is Sample.exe, copy the working copy of Is2wcgi.dll to Sample.dll. The base names must always match. Assuming your application is named SAMPLE.EXE, make sure your form ACTION is running SAMPLE.DLL. Load the form in your browser, then choose submit. If this does not work, carefully go through each test again. OTHER TECHNIQUES: Windows CGI support is not built into the IIS WWW service, because Is2wcgi.dll comes as a sample in the Win32 SDK. Because of this, you have full source code to the translator and can modify it and improve it to suit your needs. When troubleshooting, you might add MessageBox calls before all return points and determine what HSE_ constant IS2WCGI.DLL is returning. Remember to specify MB_SERVICE_NOTIFICATION because ISAPI DLLs are running as a desktop-less service. You might also make use of OutputDebugString and use Dbmon.exe to view the debug messages. DBMON will not work unless the account that the ISAPI DLL runs in has certain rights. You may also add IUSR_Guest to the administrators group temporarily for debugging. Finally, you might run IIS as a console application and step through IS2WCGI code line-by-line. See the ActiveX Readme.txt for information about running IIS as a console application. Finally, there is a constant defined in Is2wcgi.cpp that may help. Including the constant definition disables HTTP header processing by the translator, and is necessary when your Windows CGI application does not return header information. See the source code comments for details. For additional information, please see the following sources:
|
Keywords : IISAPI kbenv kbtshoot
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |