Thursday, February 16, 2012

Parallel processing of concurrent Ajax requests in Asp.Net MVC

If you want to enable a certain controller to process requests in parallel from a single user, you can use an attribute named SessionState that was introduced in MVC since version 3. It’s not necessary to use a session-less controller in order to achieve parallelism, the Ready-only option of theSessionStateBehavior will let you pass security checks you may have implemented based on Session data.
    [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
    public class ParallelController : Controller
        public JsonResult Get1()
            //read from session
            var x = Session["call"];
            return Json(new { obj = "p1" }, JsonRequestBehavior.AllowGet);
        public JsonResult Get2()…
        public JsonResult Get3()…