Debugging IIS ISAPI modules

Before I start I want to point out that this is not a product review.  I have found an excellent way to debug ISAPI DLLs and it happens to require a very inexpensive tool.  I just wanted to share this information as it has been so useful!

I've been writing some web services recently using Delphi 7 and IIS 5 and it has been a real pain to debug them.

I used to have a reference to a really good article explaining how to set up IIS as a process instead of a service and then use inetinfo.exe as the host app for the DLL, but I could no longer find it.  I tried various other articles / tools etc but was not happy with any of them.  Most articles didn't work (thank goodness for XP System Restore) and most tools are targetted at web sites so returned text/html instead of text/xml, which confused my web service client.

Yesterday I came across an ISAPI debugger HERE.  I have only been using it for 10 minutes so far and I must say it is excellent!  I didn't have to alter the registry at all, and the requests still go through IIS.  Here is how it works.

Server setup

  1. I created a virtual folder called "Debug" with script access.
  2. I placed ISAPIfwd.dll into that folder, which is a file supplied with the tool.

That's it for the server!

Client setup

  1. Open my ISAPI project in my IDE (Delphi in this case).
  2. Set the host application as ClientISAPI.exe, another file supplied with the tool.
  3. Set the run parameters of my project to the full path + filename of my ISAPI DLL.

Again, that's it!

Debugging the ISAPI

  1. I run my ISAPI project, ClientISAPI.exe runs.
  2. ClientISAPI.exe loads my DLL (which is why the runtime parameter is needed).
  3. My web service test application then calls the following url http://localhost/debug/isapifwd.dll/wsdl/IMyWebService.
  4. ISAPIfwd.dll receives the request, passes it to ClientISAPI.exe.
  5. ClientISAPI.exe then runs the required code in my ISAPI DLL, meaning that I can step through the code.
  6. ClientISAPI returns the Response to ISAPIfwd.dll, which in turn responds to the clie
  7. nt.

What I really like about this approach is:

  1. No registry modifications required.
  2. You can remotely debug on the actual deployment IIS server.
  3. It isn't weighted towards websites only, anything which goes through IIS + ISAPI can be debugged.
  4. Your ISAPI isn't cached, so no need to keep on starting/stopping IIS.


Share this article!

Follow us!

Find more helpful articles: