I have a form that posts several like named elements to an action like so:
<%= Html.TextBox("foo") %>
<%= Html.TextBox("foo") %>
<%= Html.TextBox("foo") %>
posts to and returns:
public ActionResult GetValues(string[] foo)
{
//code
return RedirectToAction("Results", new { foo = foo })
}
the “Results” action then looks like this:
public ActionResult Results(string[] foo)
{
//code
return View()
}
The issue I’m having is that after the redirect my url looks like this:
/results?foo=System.String[]
instead of the intended:
/results?foo=value&foo=value&foo=value
Is there any way to get this to work with my current set-up?
I didn’t find a solution to work with the above code. What I ended up doing was taking the array/Enumerable, looping through it, and building a query string to pass with the redirect. Something along the lines of:
This is much more simplified than the code I ended up using, but it also allowed me to drop the null values that may be submitted with the form. Cleans things up a bit.