How to Debug CGI Applications Running Under IIS
ID: Q238788
|
The information in this article applies to:
-
Microsoft Internet Information Server versions 2.0, 3.0, 4.0
SUMMARY
This article explains how to debug CGI applications running under IIS.
MORE INFORMATION
To debug a VC CGI application, do the following:
- Add the following code before including windows.h and build a debug version of the CGI:
#define _WIN32_WINNT 0x0400
- Add the following code at the beginning of the CGI:
#ifdef _DEBUG
char szMessage [256];
wsprintf (szMessage, "Please attach a debbuger to the process 0x%X (%s) and click OK",
GetCurrentProcessId(), argv[0]);
MessageBox(NULL, szMessage, "CGI Debug Time!",
MB_OK|MB_SERVICE_NOTIFICATION);
#endif
- Invoke the CGI application.
- Attach a debugger (such as Visual C) to the CGI process while a message box is on the screen.
- When the debugger is attached, open the source file and set a break point. Click OK to dismiss the message box. When the message box is dismissed, the CGI execution will resume and the break point will be hit.
To debug a VB CGI application, do the following:
- Compile the VB .exe with Symbolic Debug Info and turn off optimizations.
- Add the following Function prototype to the CGI project:
Public Declare Function Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long) As Long
- Add the following line to the beginning of the CGI Sub Main():
Sleep 60000
- Hit the CGI application with the browser.
- While the CGI is "sleeping," start Microsoft Developer Studio. On the Build menu, click Start Debug, click
Attach Process, select the Show System Processes option, and attach to the CGI process with the debugger. When
attached to the process, load the VB source file and set a break point on the line after the Sleep statement.
When the Sleep statement releases control of the application, the debugger will stop at the break point.
Keep in mind that "Sleep 60000" gives you 60 seconds to complete the above steps.
If you need more time, increase the number passed to Sleep.
For additional information, see the following article in the Microsoft Knowledge Base: Q183480 HOWTO: Debug ISAPI and Filter DLL Under IIS 4.0
REFERENCES
© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Leon Braginski, Microsoft Corporation
Additional query words:
Keywords : kbGrpInetServer kbDSupport
Version : winnt:2.0,3.0,4.0,5.0
Platform : winnt
Issue type : kbhowto
|