?
Solved

How do you debug CGI applications under IIS

Posted on 2004-11-12
9
Medium Priority
?
950 Views
Last Modified: 2010-05-18
I am programming CGI applications using MS VC 7.0 that run under IIS and I need a way to debug them.  I have tried the following examples at MS http://support.microsoft.com/default.aspx?scid=kb%3BEN-US%3B238788 but I cannot get them to work.  Is there an easier way to debug CGI appliations using MS VC 7.0?
0
Comment
Question by:marcus_carey
  • 4
  • 3
  • 2
9 Comments
 
LVL 34

Expert Comment

by:Dave_Dietz
ID: 12572121
Unfortunately there really isn't.

There is no native debugger for CGI applications so you have to use the same methods you would use for any generic win32 process.

The easiest is probably the third method (Set Service Options) since it automatically starts the process under the debugger whenever it starts, but if you are using Visual Studio as your development environment it may be easier to use the Visual Studio debugger rather than WinDBG (or CDB if you're truly masochistic...).

When you say you can't get it to work what exactly are you seeing when you try?

Dave Dietz
0
 

Author Comment

by:marcus_carey
ID: 12574300

Dave

Here is the registry entry I am using.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\debug.exe]
"Debugger"="C:\\Debugger\\bin\\winddb"

When I access the file in the web browser, I get a HTTP 404 - File not found message.
0
 
LVL 34

Expert Comment

by:Dave_Dietz
ID: 12574961
This would assume your CGI is called debug.exe and your debugger is called winddb.exe and it is in the c:\debugger\bin directory.  Is this correct, and if so what is winddb (I am not familiar with this debugger...)?

How are you trying to access your CGI - what URL are you using?

What version of IIS are you running?  Can you post an entry or two from the w3svc logs showing the 404 response?

Thanks.

Dave Dietz
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

Author Comment

by:marcus_carey
ID: 12575111
Dave

The debugger is the Microsoft® Windows® System Debugger.

http://localhost/cgi-bin/debug.exe

Here is the partial log from IIS 5.0.  The last two request show the 200 response code because I deleted the registry value.

2004-11-13 14:38:37 192.168.1.100 - 192.168.1.100 80 GET /cgi-bin/debug.exe - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CLR+1.1.4322)
2004-11-13 14:41:39 192.168.1.100 - 192.168.1.100 80 GET /cgi-bin/debug.exe - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CLR+1.1.4322)
2004-11-13 14:58:22 192.168.1.100 - 192.168.1.100 80 GET /cgi-bin/debug.exe - 200 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CLR+1.1.4322)
2004-11-13 14:58:24 192.168.1.100 - 192.168.1.100 80 GET /cgi-bin/debug.exe - 200 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CLR+1.1.4322)
 
0
 
LVL 34

Accepted Solution

by:
Dave_Dietz earned 2000 total points
ID: 12580562
Try downloading the Debugging Tools for Windows from the following link:

http://www.microsoft.com/whdc/devtools/debugging/installx86.mspx

When you install them do *not* install to the default location (c:\program files\windows tool for debugging - pain in the rear to type and won't work with the registry entry due to spaces in the path).  I would suggest something more like c:\debug.

Once this is installed try using the following:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\debug.exe]
"Debugger"="C:\\Debug\\windbg"

Also, though I *strongly* doubt this has anything to do with it, you might want to rename your CGI to something other than debug.exe to avoid any possible name conflist with debug.exe in the system32 directory (another debugger of sorts).

Dave Dietz
0
 
LVL 37

Expert Comment

by:meverest
ID: 12580618
Hi,

you can debug them inside the Vstudio environment by running it after setting appropriate environment variables.

All the cgi variables are passed to the executable as ENV.  for example, just "SET QUERY_STRING=action=2&next=whetever" then you can ready that data from the cgi exe as if it were running on a real live web server.  The output will go to stdout the same as any console application.

This is a much better way to debug your apps than getting iis involved.

Cheers.
0
 

Author Comment

by:marcus_carey
ID: 12581045
Dave

I got this work but it's a nightmare.  There has to be an easier way.  I did not understand the example posted by meverest.
0
 

Author Comment

by:marcus_carey
ID: 12581053
I will post another question for meverest if they can provide a better explanation.
0
 
LVL 37

Expert Comment

by:meverest
ID: 12581240
>> I did not understand the example posted by meverest

What i mean is that the cgi interface simply uses environment variables to deliver data to the cgi executable.

You know what data the exe expects to find, so you can simply SET those variables in the application environment, then just run the executable - it will grab all the data from ENV and display the html output to stdout.

cheers.
 
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here are the symptoms: You start receiving calls from users that one of your legacy web apps isn't coming up, so you log into your IIS 5 server to check it out.  When you pull up the services, you notice that the WWW Publishing service isn't runn…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question