title: Custom Asynchronous HTTP Handlers generate Error 500 in IIS 7.5 Integrated Mode only - Why?
body: <p>I've written a long-polling project in ASP.Net.  The client side makes an XMLHttpRequest for a page that is either "any.orders" or "any.prices".</p>
  
  <p>I have a couple of asynchronous custom http handlers that take the request, perform subscription for the request, and serve up data (notionally, the page response) at a later point in time.</p>
  
  <p>In Visual Studio's Dev server, it works fine, perfect.  In IIS 7.5 on Windows Server 2008 R2, I can only get it to work in Classic Mode.  </p>
  
  <p>If I switch to Integrated Mode (with request tracing), the XMLHttpRequest gets an Error 500 from the IsapiModule:</p>
  
  <pre><code>ModuleName:IsapiModule 
  Notification:128 
  HttpStatus:500 
  HttpReason:Internal Server Error 
  HttpSubStatus:0 
  ErrorCode:0 
  ConfigExceptionInfo:
  Notification:EXECUTE_REQUEST_HANDLER 
  ErrorCode:The operation completed successfully. (0x0) 
  </code></pre>
  
  <p>In the application logs, I can see an instance of the Async handler class being created, but the BeginProcessRequest() function is not called.  It is almost as if the IsapiModule is immediately batting back the zero return code without handling the page request.</p>
  
  <p>I have been driving myself nutty trying to get it working in Integrated Mode.  I know long-polling's days are numbered, as WebSockets is near standard, but if I could clear this up it would help my understanding of what is going on.</p>
  
  <p>The web.config sections for handler registration are below:</p>
  
  <pre><code>  &lt;system.web&gt;
  
      &lt;!-- IIS 6.0/7.0 AsyncHttpHandler Registration --&gt;
      &lt;httpHandlers&gt;
  
        &lt;add verb="*" path="*.prices" type="AsyncHttpHandlerPrices" /&gt;
        &lt;add verb="*" path="*.orders" type="AsyncHttpHandlerOrders" /&gt; 
  
        &lt;!-- For Copy and Paste into Excel --&gt;
        &lt;add verb="*" path="*.xls" type="System.Web.StaticFileHandler" /&gt;
        &lt;add verb="*" path="*.xlsx" type="System.Web.StaticFileHandler" /&gt;
  
      &lt;/httpHandlers&gt;
  
    &lt;/system.web&gt;
  
    &lt;system.webServer&gt;
  
      &lt;handlers&gt;
      &lt;remove name="svc-Integrated" /&gt;
        &lt;remove name="xoml-Integrated" /&gt;
        &lt;add name="*.vbhtml_*" path="*.vbhtml" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add name="*.vbhtm_*" path="*.vbhtm" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add name="*.cshtml_*" path="*.cshtml" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add name="*.cshtm_*" path="*.cshtm" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add name="*.aspq_*" path="*.aspq" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add name="*.xamlx_*" path="*.xamlx" verb="*" type="System.Xaml.Hosting.XamlHttpHandlerFactory, System.Xaml.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add name="*.xoml_*" path="*.xoml" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add name="*.svc_*" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add name="*.soap_*" path="*.soap" verb="*" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory, System.Runtime.Remoting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add name="*.rem_*" path="*.rem" verb="*" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory, System.Runtime.Remoting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add name="*.asmx_*" path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add name="ScriptResource.axd_GET,HEAD" path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add name="*_AppService.axd_*" path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add name="eurl.axd_*" path="eurl.axd" verb="*" type="System.Web.HttpNotFoundHandler" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add name="*.xlsx_*" path="*.xlsx" verb="*" type="System.Web.StaticFileHandler" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add name="*.xls_*" path="*.xls" verb="*" type="System.Web.StaticFileHandler" preCondition="integratedMode,runtimeVersionv2.0" /&gt;
        &lt;add verb="*" path="*.prices" name="AsyncHttpHandlerPrices" type="AsyncHttpHandlerPrices" modules="IsapiModule" scriptProcessor="c:\windows\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll" /&gt;
        &lt;add verb="*" path="*.orders" name="AsyncHttpHandlerOrders" type="AsyncHttpHandlerOrders" modules="IsapiModule" scriptProcessor="c:\windows\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll" /&gt;
      &lt;/handlers&gt;
      &lt;modules&gt;
        &lt;remove name="ServiceModel" /&gt; 
        &lt;add name="ErrorHandlerModule" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" preCondition="managedHandler" /&gt;
        &lt;add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler" /&gt;
      &lt;/modules&gt;
      &lt;validation validateIntegratedModeConfiguration="false" /&gt;
      &lt;tracing&gt;
        &lt;traceFailedRequests&gt;
          &lt;add path="*.orders"&gt;
          &lt;traceAreas&gt;
          &lt;add provider="ASP" verbosity="Verbose" /&gt;
          &lt;add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" /&gt;
          &lt;add provider="ISAPI Extension" verbosity="Verbose" /&gt;
          &lt;add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,Rewrite,RequestRouting" verbosity="Verbose" /&gt;
          &lt;/traceAreas&gt;
          &lt;failureDefinitions statusCodes="100-999" /&gt;
          &lt;/add&gt;
          &lt;add path="*.prices"&gt;
          &lt;traceAreas&gt;
          &lt;add provider="ASP" verbosity="Verbose" /&gt;
          &lt;add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" /&gt;
          &lt;add provider="ISAPI Extension" verbosity="Verbose" /&gt;
          &lt;add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,Rewrite,RequestRouting" verbosity="Verbose" /&gt;
          &lt;/traceAreas&gt;
          &lt;failureDefinitions statusCodes="100-999" /&gt;
          &lt;/add&gt;
        &lt;/traceFailedRequests&gt;
      &lt;/tracing&gt;
    &lt;/system.webServer&gt;
  </code></pre>
  
  <p>DotNet version is 4.0.  The .Net Extensibility feature is installed (as said, it works in Classic mode, so it must be good).</p>