ASP.NET MVC + jQuery + IIS6: Multiple Ajax requests

后端 未结 3 633
抹茶落季
抹茶落季 2021-01-15 21:01

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

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

$(         


        
3条回答
  •  滥情空心
    2021-01-15 21:59

    Your code works as expected on my machine. I had to insert any artificial delay with Thread.Sleep to see it in action though because the unadulterated requests executed so fast that it appeared they were all completed at once.

     System.Threading.Thread.Sleep(1000);
    
     return Content(String.Format("Thread #{0}, Started = {1:hh:mm:ss.FFF}, Completed = {2:hh:mm:ss.FFF}, Duration = {3:hh:mm:ss.FFF}, Result = {4}",
           System.Threading.Thread.CurrentThread.ManagedThreadId,
           requestStart,
           DateTime.Now,
           DateTime.Now.Subtract(requestStart),
           status));
    

    A quick test on my machine using Firefox and connecting to the built-in Visual Studio Web Server showed that two requests were executed simultaneously on the client and handled by two different threads on the server.

    As far as I know, there are a limited number of allowed concurrent requests allowed by the browser. Here is another post that on SO that covers what each value is for each of the popular browsers: How many concurrent AJAX (XmlHttpRequest) requests are allowed in popular browsers?

    EDIT: I reread your post and saw that you mentioned IIS 6. I do not have access to IIS 6, but running it on an IIS 7 Web Server with a 5 second artificial timeout (Thread.Sleep) showed that multiple requests were being handled at the same time by different server threads. None of them start at the EXACT same time, so there might be some queuing going on at the server, but with a 5 second delay it's easy to see that in Firefox 3.0 I have at least 6 concurrent requests at a time.

提交回复
热议问题