I have a ‘tabbed’ style web page where once the page loads each tab fires off an Ajax request for their content (using jQuery). The backend is ASP.NET MVC running in Visual Studio so just with the normal ‘ASP.NET Development Server’ servicing the requests. I am experiencing the following issues:
1) The requests are processed by the web server one at a time. The second request is not dealt with until the first completes. Is this the ‘ASP.NET Development Server’ running in some single threaded mode? Can I make it multithreaded (and should I make it multithreaded or would this open up a world of pain?)
2) Long running requests kill off subsequent requests. Given that the requests are being serviced one at a time even though I am firing off the ajax request all at once, why do some of the requests fail to even arrive at the web server? This happens once a long request has been serviced. For example:
- 1st Request (small request) –
response okay - 2nd Request (large
request) – response takes a minute or
so but does get serviced. - 3rd Request
(small request) – request never
arrives at the server and jQuery does
not report an error.
I have tried increasing the ajax timeout but with no success.
Update:
I have found a bug in my code that was messing up the URL to the final request so it looks like this has nothing to do with the request length and ajax timing out (blushes!). Along the way though I have found the useful ajaxManager plugin which is great for queueing up request if that is what you need (http://www.protofunc.com/scripts/jquery/ajaxManager/). Also, thanks for the valid point about using the ASP.NET Dev Server to test against. It is indeed quite different from IIS.
With regards to point 1 bear in mind that if you’re using session state then the requests will not perform concurrently – ASP.NET will lock the session state and will only process each request that uses it one at a time. (See the section ‘Concurrent Requests and Session State’ in http://msdn.microsoft.com/en-us/library/ms178581 for more info) Try disabling session state (if you’re not using it of course!) and see if that helps.