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

我只是一个虾纸丫 提交于 2019-12-01 12:22:46
DreamSonic

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.

EDIT: here's a related question

GuyIncognito

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.

You are calling your ajax request every time you find an element with the class .fedex_status.

Your line

$(".fedex_status").each

is saying do this everytime you find an element with the class .fedex_status.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!