none
MVC bug? Using TempData will prevent page loading RRS feed

  • Question

  • Hi, I found a quite weird issue about TempData in MVC development. I hope it was my mistake but I don't know...

    I make a controller to accept text from its form and put it into TempData then redirect to Index(). I pretend that the data process will cost 6 seconds so I use Thread.Sleep(6000).

            [Themed]
            public ActionResult Index()
            {
                return View();
            }
            [HttpPost]
            public ActionResult Index(FormCollection form)
            {
                Thread.Sleep(6000);
                if (!string.IsNullOrEmpty(form["aaa"]))
                    TempData["data"] = form["aaa"];
                return RedirectToAction("Index");
            }
    

    I open the page Index() and submit the form. Meanwhile, I open another browser and load Index() simultaneously. The second page can be opened with no problem when the 1st page is submitting. -- this is expected.

    After the first page has been submitted, I do the same thing: submit the page Index() again in browser A and open Index() in browser B simultaneously. The issue happened: the Index() loading in the browser B is stuck and the page cannot be opened until the submitting in browser A is finished. 

    It seems TempData causes the issue here but I have no idea why this will happen. Can anyone help? Thanks.


    • Moved by Sabah ShariqMVP Thursday, June 1, 2017 9:52 AM Moved From Visual C#
    Thursday, June 1, 2017 5:15 AM

All replies

  • Hi KYCIS,

    This is Visual C# forum. As your issue is related to Web, please ask your question into ASP.Net forum for getting quick response. I am moving your thread to off-topic.

    https://forums.asp.net/

    Your understanding and cooperation will be grateful.

    Thanks,
    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]

    Thursday, June 1, 2017 9:51 AM