Passing an ArrayList parameter to an ASP.NET MVC controller action

I am writing an application in which I need to send System.Collections.ArrayList data as a parameter from one controller action to another. I use

return RedirectToAction ("action1", "controller1", new {arrList = arrListInFirstAction});

But since the ArrayList goes out of scope in the first action, the parameter in the action-redirected gets the null parameter.

Can anyone help me find the answer to this problem.

Thank.

+1
source share
1 answer

. TempData ,

publci ActionResutl action()
{
     TempData["arr"] = new int[]{1,2,3};
     return RedirectToAction("action1");
}

Public ActionResult action1()
{
    int[] arr = TempData["arr"];
    return View();
}
+3

All Articles