Azure and HttpHandlers

2019-06-10 16:00发布

问题:

I have a HttpHandler for an asp.net mvc application. I've tested the handler for asp.net and asp.net mvc 3 applications and everything works as expected.

When I use the HttpHandler in an Azure based asp.net mvc 3 application the 'ProcessRequest' method is NOT being called - I can see the HttpHandler being created.

I have the following web.config and this works for a standard asp.net mvc 3 app:

  <system.web>
    <httpHandlers>
      <add type="TestWebRole.Infrastructure.HttpHandlers.EPubHandler"
           path="*.epub"
           verb="*" />
    </httpHandlers>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
      <add name="EPubHandler"
           type="TestWebRole.Infrastructure.HttpHandlers.EPubHandler"
           path="*.epub"
           verb="*"
           resourceType="Unspecified"
           allowPathInfo="false"
           modules="IsapiModule"
           scriptProcessor="%path%\aspnet_isapi.dll"/>
    </handlers>
  </system.webServer>

I also have the following statement in the global.asax.cs file to specify ignoring asp.net ,mvc routing for the extension type:

 routes.IgnoreRoute("{resource}.epub/{*pathInfo}");

What do I have to configure to get this working when running in Azure - locally or deployed into the cloud?

回答1:

Just to try, why don't you remove the httpHandlers section under system.web and leave only that in the system.webServer. And also strip all the unnecessary attributes from the one under system.webServer (scriptProcessor, modules, allowPathInfo).

And also you may check for any uncought exception, event log entry, anything showing some kind of error.