gpt4 book ai didi

c# - 自定义异步 HTTP 处理程序仅在 IIS 7.5 集成模式下生成错误 500 - 为什么?

转载 作者:太空狗 更新时间:2023-10-30 01:19:23 25 4
gpt4 key购买 nike

我在 ASP.Net 中编写了一个长轮询项目。客户端为“any.orders”或“any.prices”页面发出 XMLHttpRequest。

我有几个异步自定义 http 处理程序,它们接收请求、执行请求订阅并在稍后的某个时间点提供数据(名义上是页面响应)。

在 Visual Studio 的开发服务器中,它运行良好,完美。在 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)

在应用程序日志中,我可以看到正在创建异步处理程序类的实例,但未调用 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 Extensibility 功能(如前所述,它在经典模式下工作,所以它一定很好)。

最佳答案

问题是如果不在 web.config 中进行适当的更改,您无法从经典模式切换到集成模式。如果我的方法是正确的,那么这一定是您收到的错误:

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

基本上,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 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

关于c# - 自定义异步 HTTP 处理程序仅在 IIS 7.5 集成模式下生成错误 500 - 为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23113086/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com