IIS 服务器等待服务调用而不是服务下一个请求

IIS Server waiting on a Service call instead of serving the next request

我有一个 ASP.Net Web 应用程序,其中一个页面 Home.aspx 显示了一些统计信息。 The Home page has a JQuery Ajax request to load the dashboard statistics from the server. The calculating takes a few seconds and the UI is showing the loading animation. The user decides to move to a different page say HelpDesk.aspx and the request will not be served until the JQUERY AJAX request is returned. The Page HelpDesk.aspx is a static page and no logic involved hence would expect a quick response whereas the server has waited (unless the browser tools are fooling me) on the “GetDashboardStatistics” AJAX request before sending the response for the HelpDesk.aspx page.。 网络服务代码如下

    [ServiceContract(Namespace = "http://XYZ/XYZService")]
        [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
        public class XYZService{

        [WebInvoke(Method = "POST",  RequestFormat = WebMessageFormat.Json,
                  BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
        public DashboardStatisticsDTO[] GetDashboardStatistics(DashboardStatisticsRequestDTO dashboardStatisticsRequest)
        {
            var list = new List<DashboardStatisticsDTO>();
//Use Session Information to identify the user
                   //business logic to load the entity collection
             return list.ToArray();
        }

        }

我需要什么:有没有一种方法可以立即强制重定向,而不是等待服务器完成和 return 响应? IE。用户点击显示加载动画的主页,并决定在服务器响应 returned 之前离开,如何实现?

看起来问题与 AJAX 调用在 WCF 服务必须在图片中使用上下文信息时被阻止是一样的。

最后,我在 Global.asx.cs 中使用了以下代码来解决问题。

protected void Application_BeginRequest(object sender, EventArgs e)
    {   
        if (Request != null && !string.IsNullOrEmpty(Request.Path))
        {
            if (Request.Path.Contains(@".svc/"))
            {
                Context.SetSessionStateBehavior(SessionStateBehavior.ReadOnly);
            }
        }
    }

对该问题的广泛搜索发现已经发布了类似的问题,其中一些是: Question1 | Question2 和 MSDN 博客:http://blogs.msdn.com/b/silverlightws/archive/2009/09/30/having-a-pollingduplex-service-and-any-other-wcf-service-in-the-same-website-causes-silverlight-calls-to-be-slow.aspx