Issue with HTTP Handlers and IIS7

asp.nethttphandleriis-7

I've been developing a custom HTTP handler. Using the new web.config <httphandlers> section for ASP.NET 4.0 and IIS7, this works great on my development machine.

However, when I upload the code to my shared-hosting account, I get a 500 server error. I called my hosting company and they said the server was reporting an error about a web.config setting being detected that does not apply to integrated pipeline mode.

When he switched IIS from integrated to classic mode, the home page then loads okay but my routed pages all report a 403 server error.

I'm pretty sure I need integrated mode in order for the <httphandlers> section to work, but I am definitely not an IIS/admin guy. Does anyone have any idea what the problem might be or what I can try next?

EDIT: The bulk of my updated web.config:

<?xml version="1.0"?>
<configuration>
    <connectionStrings>
        [...]
    </connectionStrings>
    <appSettings>
        [...]
    </appSettings>
    <system.web>
        <httpHandlers>
            <add verb="*" path="*.zip" type="BlackBelt.ZipHttpHandler"/>
        </httpHandlers>
        <compilation debug="false" targetFramework="4.0"/>
    </system.web>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <handlers>
            <add verb="*" path="BlackBelt.ZipHttpHandler" name="BlackBelt.ZipHttpHandler" type="BlackBelt.ZipHttpHandler"/>
        </handlers>
        <!-- Redirect domain.com to www.domain.com -->
        <rewrite>
            <rules>
                <clear/>
                <rule name="WWW Rewrite" enabled="true">
                    <match url="(.*)"/>
                    <conditions>
                        <add input="{HTTP_HOST}" negate="true" pattern="^www\.([.a-zA-Z0-9]+)$"/>
                    </conditions>
                    <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent"/>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Best Answer

Thanks to Pauli, I was able to figure this out. Although <system.web><httpHandlers> is the section I must change to get it to work when running from Visual Studio, <system.webServer><handlers> is the section I must modify to get it to work when running on the server, which is running IIS7.

I've received email asking exactly how I resolved this. I've written an article that describes the exact steps and presents my code. If anyone wants to see this article, it is available at http://www.blackbeltcoder.com/Articles/asp/writing-a-custom-http-handler-in-asp-net.