Windows 7 IIS7 require some configurations to get ISAPI DLL works. It is not that straight forward compare to IIS 5.
Install IIS 7
- Go to Control Panel | Programs and Features | Turn on Windows features on or off (require privilege mode).
- Check “Internet Information Services and make sure “ISAPI Extensions” and “ISAPI Filters” is checked as well.
- Click OK button to start installation.
After finish install IIS 7, open your favorite web browser and enter URL http://localhost/ to make sure the IIS is working and running. You might need to check your firewall setting and add exception for port 80 TCP traffic if necessary.
Configure for ISAPI DLL
Add Virtual Directory
First, you may need to add a virtual directory to host your ISAPI DLL:
- Open Internet Information Service Manager (require privilege mode)
- Right click on “Default Web Site” node and click “Add Virtual Directory” of popup menu:
Enter “Alias” and “Physical Path” of the virtual directory:
Enable ISAPI for Virtual Directory
To enable ISAPI for the virtual directory:
- Select the virtual directory node (e.g.: “ISAPI” in this example).
- Double click the “Handler Mappings” icon.
- Click “Edit Feature Permissions…” in Actions panel
- A “Edit Feature Permission” dialog prompt out
- Check “Execute”.
- Click OK button to commit the changes.
Enable Directory Browsing for Virtual Directory
This is optional but is convenient. To enable Directory Browsing for a virtual directory:
- Select the virtual directory node (e.g.: “ISAPI” in this example).
- Double click the “Directory Browsing” icon.
- Click “Enable” in Actions panel.
Edit Anonymous Authentication Credentials
- Select the virtual directory node.
- Double click the “Authentication” icon.
- Click to select “Anonymous Authentication” item.
- Click “Edit…” in Actions panel.
- A dialog will prompt out.
- Checked “Application pool identity” and press OK button to commit changes.
Enable ISAPI modules
- Click on the root node.
- Double click the “ISAPI and CGI Restrictions” icon.
- Click ”Edit Feature Setting …” in Actions panel.
- Check “Allow unspecified ISAPI modules” option. This option allow any ISAPI dll to be executed under IIS. If you don’t use this option, you will need to specify a list of ISAPI DLLs explicitly.
Edit Permission for Virtual Directory
- Select the virtual directory node (e.g.: “ISAPI” in this example).
- Right click on the node and click “Edit Permission” of popup menu.
- A Properties dialog prompt out.
- Switch to “Security” page
- Click Edit button to show Permission dialog.
- Add “IIS_IUSRS” into the permission list.
Enable 32 bits ISAPI DLL on IIS 7 x64
This is only require if you are using IIS7 x64 and would like to run 32 bits ISAPI DLL on the IIS. If your ISAPI DLL and IIS7 is both x86 or both x64, you may skip this step.
- Click “Application Pools” node.
- Click “DefaultAppPool” item
- Click “Advanced Settings …” from Actions panel.
- A “Advanced Settings” dialog prompt out
- Set “Enable 32-bits Applications” to True
- Click OK button to commit changes
If you didn’t enable this options for 32 bits applications, you may encounter the following errors when execute the ISAPI from web browser:
HTTP Error 500.0 - Internal Server Error
The page cannot be displayed because an internal server error has occurred.
HTTP Error 500.0 - Internal Server Error
Module IsapiModule
Notification ExecuteRequestHandler
Handler ISAPI-dll
Error Code 0x800700c1
Requested URL http://localhost:80/isapi/isapi.dll
Physical Path C:\isapi\isapi.dll
Logon Method Anonymous
Logon User Anonymous
You may now deploy your ISAPI DLLs into the virtual directory and start execute the library from web browser.
DataSnap and ISAPI DLL
You may create Delphi DataSnap ISAPP DLL library and deploy on IIS. From time to time, you may encounter compilation error during development or deployment time if you have consume the ISAPI DLL. This is because the ISAPI DLL invoked will cache in the application pool. You are not allow to overwrite the ISAPI DLL while it’s being cached.
To overcome this problem, you need to perform Recycle operation:
- Click “Application Pools” node.
- Right click on “DefaultAppPool” item and click “Recycle…” item.
Deploying as ISAPI DLL is encourage during deployment stage as IIS will cache the ISAPI DLL for performance consideration.
However, the caching might not feasible during development stage as recycling need to be performed while overwrite the ISAPI DLL either by frequent compiling or overwriting. You may consider compile the server modules as CGI application in development time. Each invocation of CGI is a separate OS process and won’t be cache by IIS application pool.
Install CGI on IIS
- Go to Control Panel | Programs and Features | Turn on Windows features on or off (require privilege mode).
- Check “Internet Information Services and make sure “CGI” is checked.
- Click OK button to start installation.
Enable CGI Module
- Click on the root node.
- Double click the “ISAPI and CGI Restrictions” icon.
- Click ”Edit Feature Setting …” in Actions panel.
- Check “Allow unspecified CGI modules” option.
Consume DataSnap Server Methods via URL
The DataSnap server methods are using JSON as data stream via REST protocol. For example, a simple EchoString server method defined as:
type
{$MethodInfo On}
TMyServerMethod = class(TPersistent)
public
function EchoString(Value: string): string;
end;
{$MethodInfo Off}implementation
function TMyServerMethod.EchoString(Value: string): string;
begin
Result := Value;
end;
To access this method compiled in ISAPI DLL via URL, the URL is something like
http://localhost/datasnap/MyISAPI.DLL/datasnap/rest/TMyServerMethod/EchoString/Hello
and the response text will be:
{"result":["Hello"]}
Likewise, a CGI URL is
http://localhost/datasnap/MyCGI.exe/datasnap/rest/TMyServerMethod/EchoString/Hello
Reference:
- DataSnap 2010 HTTP support with an ISAPI dll; Author: Tierney, Jim
34 comments:
It was very helpful.Thanks.
Changing the default app pool is not the best choice on x64 => conflict with other applications.
It is better to create a new App Pool (32 bit without .net framework). And assign the pool to the new virtual directory.
Be carefull on production server (iis7/7.5). You do not need to authorize unknown isapi on production server, in handler mappings, you can "add Module Mapping" and specify your DLL as parameter of the isapi module.
Hi
I'm just wondering if you know a shared web hosting company supporting Delphi ISAPI.DLL's?
Thanks
Sam
Thanks for your help. This was a very good blog post, especially the part about the 32-bit settings.
Cheers, Trutz
Nice how-to, thanks! The only comment is that is really better to create a new application pool and use it with your ISAPI modules.
Best reagards
Great Article!. It works for me 100%
Thank you! It's like a miracle to find info about how to make this work. Thanks for posting this!
Thanks it was a great help and a step in the right direction but I'm still having problems connecting to a database. The Isapi dll doesn't seem to read the config file where the connection string is.
Perhaps you need to check the log and figure out why it doesn't work.
You saved my day !!!
After searching for a day I finally found this great article. This worked 100% for me.
Very Nice!!!
I wasted a good time trying this alone. My experience with configuration of II6 was not enough.
Thanks
Aceto
Thanks,
This post save a lot of working time.
Aceto
Hi,
Thank you very much for this post. If helped me configure ISS 7 to use some Delphi Isapi dlls in few minutes. Thank you again.
Hi. I have IIS on Win7 OS and wanted to run ASP.Net 4.0 and PHP5.3. ASP.Net makes no problems and works without any problem and without configuration. PHP5.3 always throws the error: HTTP-Fehler 500.0 - Internal Server Error
C:\php5\php.exe - Der FastCGI-Prozess wurde unerwartet abgebrochen. Perhaps anyone has an idea?
Perfect for Win7 64bits and ISAPI dlls.
Tks
Perfect for Win7 64bits and Delphi Dlls.
Awesome Job!
Mike Rozlog
After scratching my head for 4 hours I came across this article and get the issue fixed.
Many thanks and keep on the nice work.
THANK YOU! THANK YOU! THANK YOU! Why can't Microsoft's own documentation be this good?
You have saved me after I wasted A LOT of time following other sources. The 32-bit step was particularly important for me.
Finally, I have my old C++ ISAPI .dll working in IIS.
Thank you. This was very helpful.
Thank you very much!!!
Excellent work.
Do you also know how to run IIS as a proccess and not as Service?
[ ]s
Duran
I have no idea how to configure IIS7 to run as application. You may try ask in http://serverfault.com/
Thanks for your tutorial.I developed ISAPI web application in dephi 7.Its working fine in windows xp but its not working on windows 7 32 bit.I did the same settings in IIS7 what mention in this article.For windows xp i did the component service for particular virtual directory identity account is system account is selected.I couldn't found this settings in windows.Please help to solve this problem.I am waiting for reply.Advance thanks to you
Siva, which windows settings you refer to? Perhaps you need to read carefully and try redo everything from scratch again.
Thanks for your quick reply.I tried so many times.My Delphi XE ISAPI dll working fine in Windows XP.The same application is not running in Windows 7 32 bit.I did the same settings what u mention the steps.In windows XP InetMgr Virtual Directory Tab Application Protection is High(Isolated) settings.I couldn't found the settings in Windows 7.How i can set this settings in Windows.Please help to solve this problem.Advance thanks to you.
Thanks & Regards
Siva
With your help I finally got my ISAPI up and running. Thank you very much!
This is not pure Windows 7 specific: on Windows server 2008 you can follow the same things (OK, it's IIS7/7.5 to on that platform ;)
To bad I already figured this out myself a few days ago (this would have made my task a lot easier).
Works perfect, however for some strange reason it does not work under secure site (https/SSL). Same DLL!
really superb... it helps me to place ISAPI dlls in Windows IIS7.
Thanks, you saved me hours of headscratching
Thanks for your help.
This was a great blog post, especially the part about the 32-bit settings.
Cheers
Ernesto.
Thanks for your help.
Have a long and prosperous life :)
After configure this while i am trying to execute asp.net code which is save in c:\inetpub\webapplication1\webapplication1\default.aspx error occuted like this... what to do?? any suggestion.. i am using windows 7 ultimate 32 bit os.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
Post a Comment