Is POSTing a Dictionary to an .NET MVC action possible?
- by Brenton Alker
I have a form which contains a series of fields like:
<input type="text" name="User[123]" value="Alice" />
<input type="text" name="User[456]" value="Bob" />
...
Where the index of the User array (123 and 456) are ID's associated with the value. I'm trying to update these values in the controller.
My thinking is that a Dictionary that maps ID to name would work, but creating the action like:
public void Save(Dictionary<string, string> user) {
// ...
}
results in the user parameter being null.
So, is passing a Dictionary possible? or, is there another method to achieve this?