ASP.NET MVC and Ajax, concurrent requests?

后端 未结 6 1539
花落未央
花落未央 2020-11-27 04:15

AJAX newbie here!
At the moment in my ASP.NET MVC web app my AJAX requests appear to be getting batched or queued, im not sure.
No requests seem to be getting comp

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 04:54

    With the release of ASP.MVC 3 you can now add an attribute to your controllers to mark the Session as readonly, which allows actions to be called concurrently from the same client.

    Sessionless Controller Support:

    Sessionless Controller is another great new feature in ASP.NET MVC 3. With Sessionless Controller you can easily control your session behavior for controllers. For example, you can make your HomeController's Session as Disabled or ReadOnly, allowing concurrent request execution for single user. For details see Concurrent Requests In ASP.NET MVC and HowTo: Sessionless Controller in MVC3 – what & and why?.

    - from this DZone article.

    By adding SessionState(SessionStateBehaviour.Disabled) to your controller, the runtime will allow you to invoke multiple actions concurrently from the same browser session.

    Unfortunately I don't think there is a way to mark an action so as to only disable the session when that action is called, so if you have a controller that has some actions that require the session and others that do not, you will need to move the ones that do not into a separate controller.

    In later versions of ASP MVC you can decorate individual controller classes with the SessionStateAttribute

    [System.Web.Mvc.SessionState(System.Web.SessionState.SessionStateBehavior.ReadOnly)]
    public class MyController : Controller 
    {
    }
    

提交回复
热议问题