Reputation: 18521
I want to transfer a string aray in my url to a mvc controller .
My controller method is
public ActionResult Index(MyModel model)
and I want My model to be
public class TagEditRequestVM
{
public string ValueA { get; set; }
public List<string> MyList { get; set; }
}
what is the best url structure to call it?
Upvotes: 2
Views: 1346
Reputation: 16032
You have to use an index and the []-notation:
http://host/Controller/Index?ValueA=val&MyList[0]=item1&MyList[1]=item2
THe index hasn't to be an incrementing integer - it just has to be unique.
EDIT
Ok, thanks to the link plurby writes in his comment you can leave out the bracket notation and just repeat the property name:
http://host/Controller/Index?ValueA=val&MyList=item1&MyList=item2
Upvotes: 3