1
votes

I'm migrating an old application from classic mode to integrated mode, and the previously registered http handlers no longer work. I've placed the handlers section under system.webServer where they're supposed to go, but no dice:

<system.webServer>
  <handlers>
    ...
    <add name="zip.ashx_*" path="zip.ashx" verb="*" type="ZipDownloadHandler, Assembly" preCondition="integratedMode,runtimeVersionv2.0" resourceType="Unspecified" />
    <add name="file.ashx_*" path="file.ashx" verb="*" type="FileDownloadHandler, Assembly" preCondition="integratedMode,runtimeVersionv2.0" resourceType="Unspecified" />
    <add name="stream.ashx_*" path="stream.ashx" verb="GET" type="StreamDownloadHandler, Assembly" preCondition="integratedMode,runtimeVersionv2.0" resourceType="Unspecified" />
  </handlers>
...
</system.webServer>

But they always return 404. The config dump from

appcmd list config "Default Web Site/MyApp" -section:system.webServer/handlers

displays the handlers correctly:

<system.webServer>
  <handlers accessPolicy="Read, Script">
    ...
    <add name="zip.ashx_*" path="zip.ashx" verb="*" type="ZipDownloadHandler, Assembly" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv2.0" />
    <add name="file.ashx_*" path="file.ashx" verb="*" type="FileDownloadHandler, Assembly" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv2.0" />
    <add name="stream.ashx_*" path="stream.ashx" verb="GET" type="StreamDownloadHandler, Assembly" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv2.0" />
   ...

If I switch from stream.ashx to registering the handler path as stream.foo, I still get a 404, but the error page is different. For stream.ashx, it looks like this, and for stream.foo it looks like this.

Perhaps stream.ashx is actually triggering the *.ashx handler which then looks for a file named stream.ashx, but can't find one. I really don't know what's going on with the other handler though, because my config looks correct. Any suggestions would be appreciated.

1
Are you seeing anything in the Event Viewer for IIS? - Craig Selbert
Nothing in the Windows event viewer, and the IIS logs under inetpub simply log the URL and the 404 returned. The exact same behaviour happens with IIS express launched from VS as well, so at least that's consistent. I've gotten around this for now via a route for each handler from which I manually return an instance of the HttpHandler, but I'd still like to know what's going on here. - naasking

1 Answers

0
votes

I never did get this to work, so I simply replaced the module registration in web.config with a route handler:

RouteTable.Routes.Add("stream", new Route("stream", new RouteHandler(new StreamDownloadHandler())));
RouteTable.Routes.Add("file", new Route("file", new RouteHandler(new FileDownloadHandler())));
RouteTable.Routes.Add("zip", new Route("zip", new RouteHandler(new ZipDownloadHandler())));