Home > Articles, IIS, ISAPI/CGI > Installing an ISAPI/CGI extension on Windows 2003

Installing an ISAPI/CGI extension on Windows 2003

This is the last article that has to be rewritten since I lost my database, it is also the one that people have asked for most so it feels good to finally get it up and running again.

This article describes how to setup IIS6 on Windows 2003 to allow it to execute ISAPI and CGI extensions. For this example I’m using my own ISAPI application called Imager Resizer (which also was the reason that I wrote this article from the beginning).

Internet Information Services (IIS) Manager

First of all you need to locate your IIS Manager, if you don’t have it as a desktop icon as I have you will find it under Start->Settings->Control Panel->Administrative Tools->Internet Information Services and open it up.

IIS Manager

When the IIS Manager opens up you first click on “Web service Extensions” node in the tree view on your left. This brings up a list with the currently known ISAPI/CGI extensions on your server. At the top of the list you’ll see “All Unknown CGI Extensions” and “All Unknown ISAPI Extensions”, by default both these are prohibited and I would recommend that they stay that way. If you are running a ton of different ISAPI or CGI extensions or is just a very lazy person that doesn’t care to much about security you can allow unknown extensions to execute but remember that if someone manage to put an ISAPI or CGI extension on your server without you knowing (a flawed upload script or whatever) they can do almost anything with it. If you decide to allow all unknown extensions you can skip to the last part of the article now.

IIS Manager with expanded Action menu

To add a new extension to the list you can either go via the Action menu and selecting “Add a new Web service extension” or you can right click in the list (not on an item though!) and select the same thing.

IIS Manager with the New Web Service Extension dialog open

This dialog is quite self explanatory but I’ll describe it anyway. Here you assign a name to identify the extension, in my case I chose “Imager Resizer” for the name. Then I click the “Add” button to browse to the required files (only Imager.dll in my case) and then finally I check the checkbox with the label “Set extension status to Allowed” so I don’t have to enable it manually afterwards. After that, I simply click OK and the dialog vanishes. Now Imager Resizer will be visible in the extension list (since I took the screenshots from my production server Imager Resizer was already in the list though) and it’s status is set to Allowed.

Properties dialog for a virtual directory in IIS Manager

Now we’ve introduced Imager.dll to IIS and told it to allow it to execute, however there is one more condition that must be filled and it has been there since IIS5 and maybe even longer then that. Anyway, what you need to do is to set the “Execute permissions” for the folder that holds the extension to “Scripts and Executables”. This is done by locating the folder in the IIS Manager (under Web Sites->MySite for example), right clicking on it and then selecting properties. In the properties dialog you chose the “Virtual Directory”/”Home directory” tab and look at the bottom of it. The second combobox counting from the bottom is the “Execute permissions” (hopefully you were able to read that yourself though) and it is probably set to “Scripts only” to start with. Set it to “Scripts and Executables” and click OK.

Thats it, now you should be able to browse to your extension and see it in action. If using Imager Resizer you can use the /test action to verify that it works correctly by going to http://www.mysite.com/Imager.dll/test. It should then return a page looking something like this: http://www.kallesbildarkiv.se/cgi-bin/Imager.dll/test. Thats it for this article, hope I didn’t miss anything essential and that it will help a few people setting up Imager Resizer or any other ISAPI or CGI extensions.

Categories: Articles, IIS, ISAPI/CGI Tags:
  1. Amit
    June 23rd, 2007 at 04:45 | #1

    Can I get a copy of crazybeaver imager.dll. I cannot find it anywhere.

  2. January 29th, 2008 at 19:32 | #2

    Hi – we are hosting on shared servers with a company called Fasthosts, everything worked fine, until they had a security breach. Now they have doubled up on security and blocked use of Imager Resizer… Can you recommend anything to get them moving again. i use the script all the time as is saves armfuls of time…

    is there any other way to get the script to work in a shared hosting environment? Yours gratefully

  3. February 24th, 2009 at 14:55 | #3

    Done every step.

    But I am getting “%1 is not a valid Win32 application.” error.

    Is there anybody to help me?

  4. September 19th, 2010 at 13:19 | #4

    Hi – I am trying to install the resizer dll on a Windows Server 2008 (x64) platform for an old ASP site we support. IIS6 – IIS7 has seen quite a change though and I am running into a problem. I wondered if you had seen this?

    I have registered the dll via the ISAPI and CGI Restrictions for the Server and ticked the ‘allow extension path to execute’ checkbox.
    Using Handler Mappings for the website I have edit the script map for the Imager.dll and set:

    invoke handler only if request is mapper to: file or folder
    access: execute

    for edit feature permissions… I have set this to Read Script and Execute.

    We are getting an “Internal Application Error –
    Class not registered” message when trying to run the test page – would anyone have any suggestions?

  5. October 19th, 2010 at 12:35 | #5

    Hi snjm,

    The “Class not registered” message is because the xml-parser used in 2.4 isn’t available on newer systems. Use the latest prerelease (which probably will be the final version ever) instead and it will work:

    http://www.crazybeavers.se/SiteData/Files/Imager_Resizer/Imager_Resizer_2-5-Prerelease_2.zip

  6. Art
    May 17th, 2011 at 01:49 | #6

    Any luck on getting the imager.dll working on x64? I’m having the same issues as snjm.

  7. July 23rd, 2011 at 09:35 | #7

    dear karl,
    hope you can help us running the imager.dll on windows2008 x64. thank you

  8. July 23rd, 2011 at 21:55 | #8

    @iwahdan
    @Art

    The dll can’t be loaded by IIS in a x64 environment. If you are running under Windows 2003 (IIS6) you have to set your whole IIS to run in x86 (Google it for more info) to get it to work, under Windows 2008 (IIS7) you can set individual websites to run in x86-mode (Google that aswell) to get it to work. Also, you need to use the prerelease-version linked a few comments up.

  9. July 24th, 2011 at 15:42 | #9

    thanks a lot karl, very happy that you answer me, i have changed the defaultAppPool to be enabled 32-bit Applications to ture then i went to the default website (which i need it to be run) and right click on it manage website then advanced settings then choose the defaultAppPool to be the application pool, now this msg appears “Calling GetProcAddress on ISAPI filter “C:\inetpub\wwwroot\gam2010\cgi-bin\Imager.dll” failed”, would you like please to give me some steps to solve this problems! :) i will be thankful
    note that i cant stop using your dll beacuse most of my websites use it.

  10. July 26th, 2011 at 13:03 | #10

    @iwahdan
    It seems that you have added Imager.dll as an ISAPI filter which is wrong since it really is an ISAPI extension. You can find more info on how to set this up on the link below.

    http://blogs.msdn.com/b/rakkimk/archive/2010/02/15/iis7-how-to-configure-a-custom-isapi-extension.aspx

  11. July 27th, 2011 at 15:08 | #11

    thanks a lot Mr. Karl, really i appreciate your help, i did every step mentioned in the article of your last reply in addition to that i convert the cgi-bin folder to application which contain the imager.dll and to be enabled on 32-bit application, now the error message different from previous and it said “The specified file does not exist.” when i call the
    page http://localhost/cgi-bin/Imager.dll/test
    so how you can help me now :)

  12. July 27th, 2011 at 15:08 | #12

    thanks a lot Mr. Karl, really i appreciate your help, i did every step mentioned in the article of your last reply in addition to that i convert the cgi-bin folder to application which contain the imager.dll and to be enabled on 32-bit application, now the error message different from previous and it said “The specified file does not exist.” when i call the
    page http://localhost/cgi-bin/Imager.dll/test
    so how you can help me now :)
    remember that the website running on windows 2008 server 64bit (iis7)

  13. August 20th, 2011 at 14:25 | #13

    any help???

  14. August 22nd, 2011 at 21:17 | #14

    Have you allowed execution of isapi-filters and Imager.dll as described in this guide? That is usually the problem when getting a 404 on Imager.dll.

  15. August 26th, 2011 at 09:27 | #15

    Hello Karl,
    thanks a lot for your help, i appreciate your help, thanks again :)

  16. opp
    May 5th, 2012 at 13:34 | #16

    Hello Karl,
    how can i get imager resizer 2.5 (your link is dead)
    i used 2.4 version and found problem “class not registered”

  1. No trackbacks yet.