I am trying to have a parallel functionality in my asp.net mvc 2 application. I have loaded a list of ip address in a table format in my view. And I want to see if they are pingable. So I fire up GetStatus(string ip) action on controller for every ip address with the help of jQuery.ajax(). I can see in firebug that all requests has been fired up. But on the server side in log4net logs I can see those requests are executed in sequential manner.
So I have 2 questions here
-
Are asp.net mvc actions are single user? meaning what if one action is called by multiple users, will that particular action will execute one-by-one for each user and not on separate (magical) thread created by asp.net or IIS?
-
What should be my approach to make it parallel, as ping is a network operation.
I work on asp.net but this aspect seems new to me. Any resources specific in this context are most welcome.
Edit: I am working on Asp.Net MVC 2
This will happen if you use sessions in your actions. Since sessions are not thread safe ASP.NET serializes access to them. So if you have 2 parallel requests for the same action from the same session (which is the case with AJAX requests) and if this action writes to the ASP.NET session, those 2 requests will be queued and executed sequentially.
If you disable the session in your web.config (
<sessionState mode="Off" />) or you disable it for the given controller, requests will no longer be processed sequentially but in parallel. Of course this means that this controller should either not use the session at all or only use it for read-only. See the[SessionState]attribute: