JQuery Ajax - running multiple queries from ASP.NET MVC

I have a tabbed style webpage that, when the page loads each tab, launches an Ajax request for their contents (using jQuery). The backend is an ASP.NET MVC running in Visual Studio, so with the usual "ASP.NET Development Server" serving requests. I am experiencing the following issues:

1) Requests are processed by the web server in turn . The second request is not processed until the first completion. Is this "ASP.NET Development Server" running in some kind of single-threaded mode? Can I make it multithreaded (and should I make it multithreaded or will it open the world of pain?)

2) Long-term requests kill subsequent requests. Given that the requests are served one at a time, even if I dismiss the ajax request all at once, why some of the requests cannot even reach the web server? This happens when a long request is being served. For instance:

  • 1st request (small request) - the answer is in order
  • The second request (large request) - the answer takes a minute or so, but I get service.
  • Third request (small request) - the request never arrives at the server, and jQuery does not report an error.

I tried to increase the ajax timeout, but without success.


Update: I found an error in my code that messed up the url for the final request, so it looks like it has nothing to do with the request length and ajax timeout (blush!). Along the way, although I found a useful ajaxManager plugin that works great for queues if that is what you need (http://www.protofunc.com/scripts/jquery/ajaxManager/). Also, thanks for the valid point about using ASP.NET Dev Server for testing. This is really very different from IIS.

+2
source share
1 answer

As for point 1, remember that if you use session state, then the requests will not be executed at the same time - ASP.NET will block the session state and will process only each request that uses it one at a time. (See the “Parallel Queries and Session State” section at http://msdn.microsoft.com/en-us/library/ms178581 for more information) Try disabling the session state (if you are not using it) of course!) And see whether it helps.

+4
source

Source: https://habr.com/ru/post/1401892/


All Articles