I am posting a form to an MVC4 controller-action. I am iterating over the FormCollection
as so:
[HttpPost]
public ActionResult Details(string nctId, FormCollection collection)
{
foreach (var key in collection.AllKeys)
{
var value = Request.Form[key]; // <-- breakpoint here
}
return RedirectToAction("Details", new { nctId = nctId });
}
I (think I) am submitting a form with the following select
inputs:
However, when I place a breakpoint on the indicated line, I see the following results:
As you can see, the values are "off by one."
What might cause this issue?
The break-point happens before the assignment occurs.
Press F10 once to advance execution over the assignment and see the updated (and correct) pairing. Alternatively, verify that all is well by inspecting Request.Form
directly.