簡體   English   中英

自定義異步HTTP處理程序僅在IIS 7.5集成模式下生成錯誤500 - 為什么?

[英]Custom Asynchronous HTTP Handlers generate Error 500 in IIS 7.5 Integrated Mode only - Why?

我在ASP.Net上寫了一個長期投票項目。 客戶端為“any.orders”或“any.prices”的頁面創建XMLHttpRequest。

我有幾個異步自定義http處理程序,它們接收請求,為請求執行訂閱,並在稍后的時間點提供數據(在概念上,頁面響應)。

在Visual Studio的Dev服務器中,它工作正常,完美。 在Windows Server 2008 R2上的IIS 7.5中,我只能讓它在經典模式下工作。

如果我切換到集成模式(帶有請求跟蹤),XMLHttpRequest將從IsapiModule獲取錯誤500:

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) 

在應用程序日志中,我可以看到正在創建的Async處理程序類的實例,但未調用BeginProcessRequest()函數。 這幾乎就像IsapiModule在沒有處理頁面請求的情況下立即回擊零返回碼。

我一直在瘋狂地試圖讓它在集成模式下工作。 我知道長輪詢的日子很多,因為WebSockets接近標准,但是如果我能清楚這一點,它將有助於我了解正在發生的事情。

處理程序注冊的web.config部分如下:

  <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版本是4.0。 安裝.Net可擴展性功能(如上所述,它在經典模式下工作,因此它必須是好的)。

問題是,如果沒有 web.config中相應的更改, 則無法從經典模式切換到集成模式。 如果我是在正確的方式,這必須是你收到的錯誤:

檢測到的ASP.NET設置不適用於集成管理管道模式

基本上,ASP.NET驗證web.config中的正確配置,如果配置文件具有不適用的設置,則返回500錯誤。 你有兩種方法可以做到:

第一種方法是禁用 ASP.NET執行的驗證以驗證集成模式的配置。

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

第二個是遷移配置設置。 本文檔非常有用: http//msdn.microsoft.com/library/bb515251.aspx

更新:

我專注於問題,而不是你的問題(為什么?)。 這就是為什么: http//mvolo.com/breaking-changes-for-aspnet-20-applications-running-in-integrated-mode-on-iis-70/

希望對你有幫助

更新2:

在這里你有兩個SO問題和他們對同一問題的非常好的答案:

HTTP錯誤500.22 - 內部服務器錯誤(檢測到ASP.NET設置不適用於集成管理管道模式。)

檢測到的ASP.NET設置不適用於集成管理管道模式

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM