Configuring an ISAPI Extension on web.config

Unanswered Configuring an ISAPI Extension on web.config

  • Wednesday, December 15, 2010 8:12 AM
     
      Has Code

    Hi,

    I have a native ISAPI extension which I need to use on a web app that I'm uploading to Azure. 
    The first step was to allow it on the IIS CGI and ISAPI Restrictions list, and this is done using a startup task (more on that here).

    Now I need to configure it on the web.config file, which is done as follows:

     <system.webServer>
     <handlers accessPolicy="Read, Execute, Script">
      <add name="DT" path="*.moo" verb="*" modules="IsapiModule" scriptProcessor="Test.dll" resourceType="Unspecified" requireAccess="Execute" />
     </handlers>
     </system.webServer>
    

    My problem here is the the scriptProcessor attribute requires the full path to the DLL. The full path on Azure will be "%roleroot%\approot\bin\Test.dll" and the problem is that I can't use environment variables inside the web.config file...

    Is there a workaround for that? or should I write code that puts the right value in this attribute?

    Many thanks,
    Shay.


    Shay Friedman | Visual C# MVP | Blogger, podcaster, author, speaker and geek! | Twitter: http://twitter.com/ironshay | Blog: http://IronShay.com

All Replies

  • Wednesday, December 15, 2010 10:03 PM
     
      Has Code
    My problem here is the the scriptProcessor attribute requires the full path to the DLL. The full path on Azure will be "%roleroot%\approot\bin\Test.dll" and the problem is that I can't use environment variables inside the web.config file...

    Forgive my ignorance, but are you sure that the web.config doesn't support environment variable expansion? I see several cases in the applicationHost.config file where the path to the handler is specified with an environment variable.

    <system.webServer>
     <handlers>
       ...
       <add name="PageHandlerFactory-ISAPI-2.0" path="*.aspx" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="0" />
       <add name="SimpleHandlerFactory-ISAPI-2.0" path="*.ashx" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="0" />
       <add name="WebServiceHandlerFactory-ISAPI-2.0" path="*.asmx" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="0" />
       <add name="HttpRemotingHandlerFactory-rem-ISAPI-2.0" path="*.rem" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="0" />
       <add name="HttpRemotingHandlerFactory-soap-ISAPI-2.0" path="*.soap" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="0" />
      ...
     </handlers>
    </system.webServer>
    
  • Saturday, December 18, 2010 10:49 PM
     
     
    Well, the fact is that when I write "%roleroot%\approot\bin\Test.dll" as the scriptProcessor it doesn't work, but when I write the full path to the file everything works fine...



    Shay.

    Shay Friedman | Visual C# MVP | Blogger, podcaster, author, speaker and geek! | Twitter: http://twitter.com/ironshay | Blog: http://IronShay.com
  • Saturday, December 18, 2010 11:41 PM
     
     

    Then I guess that %roleroot% is not defined in the context where this is used. Are you running in full IIS mode? Does it work if you change to legacy mode using hosted web core (comment out the <sites> element in web.config)?

    The other thing you could try, if you are running in full IIS mode, is to change LoadUserProfile in the application pool defaults to true.

     

  • Sunday, December 19, 2010 7:49 AM
     
     

    I am running in full IIS mode. I must do that because my ISAPI extension is a 32bit file and the client can't find the guy who wrote it so we're stuck with the 32bit version...

    Changing the LoadUserProfile to True didn't work.

    I'm trying now to add the handler using appcmd, but I run into another obstacle - how do I know the name of the website on the remote IIS? looking at my local IIS, the name of the web site is not very straight forward.

    Thanks,
    Shay.


    Shay Friedman | Visual C# MVP | Blogger, podcaster, author, speaker and geek! | Twitter: http://twitter.com/ironshay | Blog: http://IronShay.com