ASP.NET MVC + jQuery的+ IIS6:多个Ajax请求 [英] ASP.NET MVC + jQuery + IIS6: Multiple Ajax requests

查看:125
本文介绍了ASP.NET MVC + jQuery的+ IIS6:多个Ajax请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道问题出在哪里?

I'm not sure where the problem is...

我有带包的列表检查包中的页面上的跟踪信息一个Ajax请求:

I have an ajax request that checks the tracking information for a package on a page with a list of packages:

$(".fedex_status").each(function() {

    var item = this;

    // some code to construct tracking_url

    $.ajax({
         type: "GET", 
         url: tracking_url, 
         async: true, 
         cache: false, 
         success: function(data) { $(item).html("(" + data  + ")"); }, 
         error: function() { $(item).html("request failed...");} 
         });
 });

因此​​,如果有在页面上10包(10事情类的fedex_status')创建10个请求。请求工作得很好,但结果被返回一次(以串行方式)。我添加了一个时间戳到控制器动作中请求的启动和停止:

So if there are 10 packages on the page (10 things with class 'fedex_status') 10 requests are created. The requests work fine, but results are returned one at a time (in a serial manner). I added a timestamp to the start and stop of a request within the controller action:

    public ActionResult Fedex(string trackingNumber)
    {
        DateTime requestStart = DateTime.Now;

        TrackingService tracking = new TrackingService();

        string status = tracking.FedexTrackingNumberStatus(trackingNumber);

        return Content(status + " - " + requestStart.ToString("hh:mm:ss.FFF") + " - " + DateTime.Now.ToString("hh:mm:ss.FFF"));
    }

时间戳重叠无。因此,控制器被处理在一个时间的要求之一。这似乎是蹩脚的。

None of the timestamps overlap. So the controller is processing the requests one at a time. This seems crappy.

现在,Ajax请求应该是平行的。这肯定会立即返回(其异步)。当我看到IIS日志的请求具有相同的时间戳控制器动作的回报。

Now, the ajax request 'should' be parallel. It definitely returns immediately (its asynchronous). When I look at the IIS logs the requests have the same timestamp as the controller action return.

所以我的问题是:是的jquery不发送的所有Ajax请求并行或IIS或ASP.NET仅处理请求串行。我是一个大的小白与IIS和AS​​P.NET的技术细节,也许它永远被错误配置,并只响应在一个时间上的一切一个请求(仅限内部使用,低流量)。这就是说,我也是在jQuery的白痴和不知道如何当请求实际上是被解雇测试(我所知道的是$就调用立即返回)。

So my question is: is jquery not sending all the ajax requests in parallel or is IIS or ASP.NET only processing requests serially. I'm a big noob with IIS and the technical details of ASP.NET, so maybe its been misconfigured forever and only responds to one request at a time on everything (its internal use only, low traffic). That said, I'm also an idiot at jquery and not sure how to test when the requests are actually being fired (all I know is the $.ajax call returns immediately).

谢谢!

推荐答案

在理论上,ASP.NET与会话状态启用锁定为每个用户请求的会话,从而处理它们串联。我不认为你可以为MVC项目禁用会话怕疼,因为TempData的比如默认使用会话。不过你可以试试。

In theory, ASP.NET with Session state enabled locks the session for each user request, thus processing them serially. I don't think you can disable Session for an MVC project painlessly, because TempData for example uses session by default. But you can try.

编辑:这里是一个相关问题

这篇关于ASP.NET MVC + jQuery的+ IIS6:多个Ajax请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆