Passing ArrayList parameter to controller action ASP.NET MVC

后端 未结 1 1486
太阳男子
太阳男子 2021-01-26 00:01

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

return Redir         


        
相关标签:
1条回答
  • 2021-01-26 00:51

    you can not send complex types as route parameters. you can, however, use TempData collection to keep that object for one request and on next request it will be automatically removed from collection

    publci ActionResutl action()
    {
         TempData["arr"] = new int[]{1,2,3};
         return RedirectToAction("action1");
    }
    
    Public ActionResult action1()
    {
        int[] arr = TempData["arr"];
        return View();
    }
    
    0 讨论(0)
提交回复
热议问题