How to User HttpHandler such as .ashx file with IIS7 Integrated Mode, Webfarm Environment

Recently, we’ve moved our hosting for the Silicon Valley Code Camp to MOSSO, which is a hosted web farm.  In order to run modules and handlers, it seems it’s necessary to run in IIS7’s integrated mode.  Once this is set, other small issues creep up like for example you can no longer run HttpHandler’s from the standard HttpHandler’s section in your web.config file (see below)

            <remove verb="*" path="*.asmx"/>
            <add verb="*" path="*.asmx" validate="false" ...
            <add verb="*" path="*_AppService.axd" validate="false" ...
            <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler,..
            <add type="PeterKellner.Utils.CaptchaTypeHandler" verb="GET" path="CaptchaType.ashx"/>


In order to make this work, you have to do two things.  First, as MOSSO suggest on their web site you need to set a section in your <system.webServer> section called <staticContent>.  Second, you need to add to the the same handler you defined in the old section to the <handlers> section of the <system.webServer> section.  Make sure you add a name tag because that’s required in this section, where as it’s not required in the <HttpHandlers> section.

    <validation validateIntegratedModeConfiguration="false"/>
      <mimeMap fileExtension=".ashx" mimeType="text/html" />
    <modules  runAllManagedModulesForAllRequests="true"  >
            <remove name="ScriptModule"/>
            <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers....
      <add type="HealthMonitor.GeneralErrorModule,HealthMonitor" name="GeneralErrorModule"/>
            <remove name="WebServiceHandlerFactory-Integrated"/>
            <remove name="ScriptHandlerFactory"/>
            <remove name="ScriptHandlerFactoryAppServices"/>
            <remove name="ScriptResource"/>
            <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System....
            <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"...
            <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" ...
      <add name="CapthaTypeHandler" type="PeterKellner.Utils.CaptchaTypeHandler" verb="GET" path="CaptchaType.ashx"/>

Hope this saves you some time!

About Peter Kellner

Peter is a software professional specializing in mobile and web technologies. He has also been a Microsoft MVP since 2007. In addition, he’s a multi-course video author at Pluralsight. To read more about Peter Kellner and his experience click here. For information about how Peter Kellner might be able to help you with your project click here.

Follow me:


  1. Hello there, I discovered your web site by way of Google even as looking for a related subject, your website got here up, it seems good. I have bookmarked it in my google bookmarks.

  2. thanks a millions! Peter.

  3. Hi could you please attach whole text. starting from :

    Now it is unreadable.

    Thank you.

  4. Given these findings, the Court held that Ms. ,

  5. Binjie Zhao says:

    Very helpful, saved my day! Thanks a lot for sharing.

  6. But it works with IE only ūüôĀ

  7. Good find!

    Our ambigrams are hosted with Mosso as well, and are all generated through customer HTTPHandlers.

    However, we don’t have the staticcontent element in our web.config. It also seems to work just fine to set the contenttype in the handler. Like this:


    We have both text and image content type handlers, and this line of code works for both. However, if we leave that out, we also have big issues.

    Anyway, just through I would let you know about another alternative.


Get every new post delivered to your Inbox

Join other followers: