1

I have post request that contains the key "Items[]" with a value like "2,3,12".

I have a controller method that uses the following input model.

public class InputModel
{
    public int[] Items { get; set; }
}

Currently "Items" never get set.

Am I doing something wrong (wrong type in my input model, missing an attribute etc) or is there no built-in functionality for this kind of binding?

Pingvinen
  • 65
  • 1
  • 5

1 Answers1

1

You really need to post an array of integers? Send up a comma-delimited list like so in the form post:

Items=1,2,3

Spaces between the 1, 2, 3 wouldn't matter.

  • The data comes from checkboxes. I have tried posting the values as an array "[1,2,3]" and as "1,2,3", but neither is put into my input model. It is easy to generate an array from the string in the controller, but I would rather have it put directly into my input model. – Pingvinen Mar 11 '12 at 17:12