4

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".

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.

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.

If I switch to Integrated Mode (with request tracing), the XMLHttpRequest gets an Error 500 from the IsapiModule:

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) 

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.

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.

The web.config sections for handler registration are below:

  <system.web>

    <!-- IIS 6.0/7.0 AsyncHttpHandler Registration -->
    <httpHandlers>

      <add verb="*" path="*.prices" type="AsyncHttpHandlerPrices" />
      <add verb="*" path="*.orders" type="AsyncHttpHandlerOrders" /> 

      <!-- For Copy and Paste into Excel -->
      <add verb="*" path="*.xls" type="System.Web.StaticFileHandler" />
      <add verb="*" path="*.xlsx" type="System.Web.StaticFileHandler" />

    </httpHandlers>

  </system.web>

  <system.webServer>

    <handlers>
    <remove name="svc-Integrated" />
      <remove name="xoml-Integrated" />
      <add name="*.vbhtml_*" path="*.vbhtml" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="*.vbhtm_*" path="*.vbhtm" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="*.cshtml_*" path="*.cshtml" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="*.cshtm_*" path="*.cshtm" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="*.aspq_*" path="*.aspq" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <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" />
      <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" />
      <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" />
      <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" />
      <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" />
      <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" />
      <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" />
      <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" />
      <add name="eurl.axd_*" path="eurl.axd" verb="*" type="System.Web.HttpNotFoundHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="*.xlsx_*" path="*.xlsx" verb="*" type="System.Web.StaticFileHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="*.xls_*" path="*.xls" verb="*" type="System.Web.StaticFileHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add verb="*" path="*.prices" name="AsyncHttpHandlerPrices" type="AsyncHttpHandlerPrices" modules="IsapiModule" scriptProcessor="c:\windows\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll" />
      <add verb="*" path="*.orders" name="AsyncHttpHandlerOrders" type="AsyncHttpHandlerOrders" modules="IsapiModule" scriptProcessor="c:\windows\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll" />
    </handlers>
    <modules>
      <remove name="ServiceModel" /> 
      <add name="ErrorHandlerModule" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" preCondition="managedHandler" />
      <add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler" />
    </modules>
    <validation validateIntegratedModeConfiguration="false" />
    <tracing>
      <traceFailedRequests>
        <add path="*.orders">
        <traceAreas>
        <add provider="ASP" verbosity="Verbose" />
        <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
        <add provider="ISAPI Extension" verbosity="Verbose" />
        <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,Rewrite,RequestRouting" verbosity="Verbose" />
        </traceAreas>
        <failureDefinitions statusCodes="100-999" />
        </add>
        <add path="*.prices">
        <traceAreas>
        <add provider="ASP" verbosity="Verbose" />
        <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
        <add provider="ISAPI Extension" verbosity="Verbose" />
        <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,Rewrite,RequestRouting" verbosity="Verbose" />
        </traceAreas>
        <failureDefinitions statusCodes="100-999" />
        </add>
      </traceFailedRequests>
    </tracing>
  </system.webServer>

DotNet version is 4.0. The .Net Extensibility feature is installed (as said, it works in Classic mode, so it must be good).

Kiquenet
  • 14,494
  • 35
  • 148
  • 243
Steve Hibbert
  • 2,045
  • 4
  • 30
  • 49
  • 1
    Not a direct answer to your question, but something that I found helpful was to install IIS on your dev box (via Windows/Add Programs&Features). If you then run VS under local admin you can debug directly on the local IIS. Saved me a lot of hassle with similar setup/config issues. – steve cook Apr 19 '14 at 05:59
  • Do any of your handlers make use of impersonation? – Nathan Apr 19 '14 at 06:23
  • IIS on Dev box - very good suggestion, I will try this, thanks. Handlers do not use Impersonation; I have used Network Service as the user for the app pool. – Steve Hibbert Apr 19 '14 at 11:35

1 Answers1

4

The problem is that you cannot switch from Classic Mode to Integrated Mode without the appropiated changes in the web.config. If I am on the right way, this has to be the error that you receive:

An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

Basically, ASP.NET verifies the proper configuration in the web.config and returns a 500 error if the config file has settings that do not apply. You have two ways to do it:

The first way is to disable the validations that ASP.NET performes to verify the configuration for Integrated Mode.

<configuration>
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
    </system.webServer>
</configuration> 

The second one is to migrate the config settings. This document will be useful: http://msdn.microsoft.com/library/bb515251.aspx

Update:

I was focused on the problem and not in your question (why?). Here you have why: http://mvolo.com/breaking-changes-for-aspnet-20-applications-running-in-integrated-mode-on-iis-70/

I hope you find it useful

Update 2:

Here you have two SO questions and their very good answers about the same problem:

HTTP Error 500.22 - Internal Server Error (An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.)

An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode

Community
  • 1
  • 1
lontivero
  • 5,235
  • 5
  • 25
  • 42
  • Quote from http://msdn.microsoft.com/library/bb515251.aspx: Section - Moving a web application to Classic Mode: "However, if you run the application in Integrated mode, you must remove the modules and scriptProcessor attributes." – Steve Hibbert Apr 23 '14 at 11:10
  • Above is the solution to this problem. I had to edit my web.config file, in the system.webServer, handlers section, where the custom handler is configured. In the add section for each of my custom handlers, I had to REMOVE the modules and scriptProcessor attributes. Now working! I had applied the validation tweak and the appcmd migrate step, but it seems you need to do this part manually. I will chuck @lontivero the points for the assistance (thanks), and I hope this helps anyone else who gets the cryptic "500 Operation Completed Successfully" error code. – Steve Hibbert Apr 23 '14 at 11:18