【发布时间】:2014-04-16 14:57:51
【问题描述】:
我在 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)
在应用程序日志中,我可以看到正在创建 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 Extensibility 功能已安装(如前所述,它在经典模式下工作,所以它一定很好)。
【问题讨论】:
-
不是对您问题的直接回答,但我发现在您的开发盒上安装 IIS (通过 Windows/添加程序和功能)很有帮助。如果您随后在本地管理员下运行 VS,则可以直接在本地 IIS 上进行调试。为我省去了很多类似设置/配置问题的麻烦。
-
您的任何处理程序是否使用模拟?
-
开发盒上的 IIS - 非常好的建议,我会试试这个,谢谢。处理程序不使用模拟;我已将网络服务用作应用程序池的用户。
标签: c# asp.net iis asynchronous httphandler