1

I want to implement something like this:

public ActionResult ListOfErrors(List<string> listOfErrors)
{
     somelogic;
}

public ActionResult SomeAction()
{
    List<string> newList = new List<string>(){"aaaa","bbbb","cccc"};
    return RedirectToAction("ListOfErrors", newList);
}

But listOfErrors in Action ListOfErrors is a 1 item list with value: System.Collections.Generic.List`1[System.String]

Can it be done?

EDIT: I've changed route values based on suggestion on comments but in redirected Action I get null in a List parameter.

Pomme
  • 87
  • 8

1 Answers1

0

You might require foreach loop to iterate each and every member of your list. You need something like:

foreach ( var item in newList )
   {
       //Your Logic

   }

Yes! you can pass a list of strings as a parameter to Controller's Action

Check these Links:

Passing-Liststring-to-string-parameter

Convert List string

Abhishek Duppati
  • 610
  • 6
  • 18