Problem with HTTP and IIS7 handlers

I am developing my own HTTP handler. Using the new web.config section <httphandlers>for ASP.NET 4.0 and IIS7, this works fine 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 that the server reports an error related to setting the web.config parameter, which does not apply to the integrated conveyor mode.

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

I'm sure I need integrated mode for the partition to <httphandlers>work, but I'm definitely not the IIS / admin guy. Does anyone know what could be the problem or what can I 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>
+3
source share
1 answer

Thanks to Pauli, I was able to figure this out. Although <system.web><httpHandlers>this is a section that I must change to make it work when working in Visual Studio, it <system.webServer><handlers>is a section that I need to change to make it work when working on a server running IIS7.

, . , . - , http://www.blackbeltcoder.com/Articles/asp/writing-a-custom-http-handler-in-asp-net.

+6

Source: https://habr.com/ru/post/1785587/


All Articles