Rick Strahl's Weblog
Rick Strahl's FoxPro and Web Connection Weblog
White Papers | Products | Message Board | News |

IIS 7 and ISAPI Dlls in a BIN directory


May 02, 2007 •

IIS 7 ships with a set of built in URL restrictions similar to URLMon natively. These settings are configurable via Configuration files  - specifically in Applicationhost.config in the \windows\system32\inetsvr directory in the system.webserver/security/requestFiltering/hiddenSegments section specifically.

 

What this means is that when you try to run your Web Connection ISAPI extension out of the BIN directory and you reference a URL like this:

 

Bin/wc.dll?wwDemo~ShowSomePage

 

will cause a problem. IIS 7’s filtering doesn’t allow direct access to anything in the BIN directory be it static content or dynamic executables like the Web Connection ISAPI DLL.

 

So there are a few solutions to this problem:

 

Move the DLL to a different Folder

The restriction is specific to the BIN directory and content within it so you could simply move the DLL to a different directory from which it then is accessible.

 

Override the Configuration Settings

You can go into the applicationhost.config file and basically override the system.webServer/security/requestFiltering/hiddenSegments section and adjust. As needed. One problem is that by default this section is configured not to allow overriding at lower level .config files so this pretty much means you have to override the value right there in applicationHost.config. It’s ugly and not recommended.

 

Use Scriptmaps

We’ve been recommending using ScriptMaps for EVERYTHING in Web Connection for some time, and this is yet another reminder of why you should always use scriptmaps for requests and never reference the DLL directly. Besides the ugly syntax of wc.dll directly which requires positional parameters (at least for the handler and method name) it also forces ugly Urls and forces you to hard code a path which is never a good thing.

 

The latter of these solution is the recommended one and fixing problems with an application that moves to IIS and has BIN directory depencies might be as easy as doing a global replace for any reference to bin/wc.dll and replacing it with wc.wc. So you can turn a URL like this:

 

bin/wc.dll?wwDemo~TestPage

 

into:

 

wc.wc?wwDemo~TestPage

 

Or even better use an application specific scriptmap and turn either of those ugly Urls into:

 

Testpage.wwd

 

All of these solutions require changing links which is always a pain because it's often difficult to hunt down all the places where links are embedded (in HTML pages, in code etc.). I can attest to that myself <s>.

 

I have to admit – blush – that the Web Connection samples haven’t exactly set the best example in this respect with a bunch of code still referencing the DLL directly. For version 5.22 the samples and admin links have been updated to remove the DLL links.

 

Another reason to start thinking about this is that for future versions Web Connection will provide a managed .NET module to take over the ISAPI connector functionality. This connector actually ships in beta form in the 5.22 release - although the module is a DLL it can never be referenced directly and is only accessible through script maps. I'll have mroe on the new connector in another post.

 

Posted in:

Feedback for this Weblog Entry