I work on a .NET web application, targeting multiple .NET and IIS versions, that is delivered with a web.config file. We've been able to use the same web.config file for most setups, but we have one line that is giving us trouble.

One of our /configuration/system.web/handlers needs to specify a path to the aspnet_isapi.dll.

<remove name="ASP.Net-ISAPI-Wildcard" />
<add name="ASP.Net-ISAPI-Wildcard" path="*" verb="*" type="" modules="IsapiModule"
 resourceType="Unspecified" requireAccess="None" allowPathInfo="false"
 preCondition="runtimeVersionv2.0" responseBufferLimit="4194304" />

As you can see, the path points directly to a framework version, which causes problems since some people are 32-bit users (who use Microsoft.Net\Framework) and others are 64-bit users (who use Microsoft.Net\Framework64).

Is there an environment variable, like %windir%, that I can use to specify the path to the right framework version, without having to hard-code a path to the .NET DLLs?


To answer your specific question, no, there's no environment variable for the asp.net isapi module.

With managed handlers this is not a problem, you just specify the type name and signature of the assembly you want, and IIS will load it from the Global Assembly Cache

For ISAPI modules however, you still need to provide a path, but what you can do is define 2 handlers and give them different preconditions based on the hosting application:

<remove name="ASP.Net-ISAPI-Wildcard" />
<add name="ASP.Net-ISAPI-Wildcard-64" 
 preCondition="runtimeVersionv2.0,bitness64" />
<add name="ASP.Net-ISAPI-Wildcard-32" 
 preCondition="runtimeVersionv2.0,bitness32" />

(details left out to emphasize relevant attributes)

  • Let me try this at work tomorrow before accepting. Thanks! Dec 18 '13 at 5:23
  • Worked for me! Have some rep. Dec 18 '13 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.