How you call the RedirectToAction () method may not matter.
For me, the solutions presented above did not work, because the RedirectToAction () method creates a RouteValueDictionary using the .ToString () value of each property in the model. This will only work if all the properties in the model are simple, and does not work if any properties are complex objects, lists, collections, etc. because this method does not use recursion.
If, for example, a model named MymodelOrganization contains the List Employees property, then this property will result in the value of the query string .... & amp; Servants = System.Collections.Generic.List'1 [System.String] and the binding will fail, and you will get (as in my case) ... null
I had this problem, so I made a copy of my model containing only form elements, deleted my lists and passed it inside RedirectToAction (). Once in a different method of action, I was able to rebuild my lists and add them to my model before calling the last return. Good luck. Here is the idea in my code:
[HttpPost] public ActionResult ItemSubmissionForm(CombinedModelContent membervalues) { ... ItemSubmissionsDBFields aFieldsList = membervalues.FieldsList; //Stripping other objects return RedirectToAction("ItemSubmissionConfirm", aFieldsList); } [HttpGet] public ActionResult ItemSubmissionConfirm(ItemSubmissionsDBFields aFieldsList) { ... List<SomeArea> SomeAreaitems = new List<SomeArea>(); SomeAreaitems.Add ... CombinedModelContent copymembervalues = new CombinedModelContent(); copymembervalues.SomeCodeLists = SomeAreaitems; copymembervalues.FieldsList = aFieldsList; return View("SomeConfirmPage", copymembervalues);
Mario levesque
source share