Sending an array of complex objects in the get string in C# ASP.NET MVC
- by Mr Snuffle
Hi,
I want to send an array of objects in the get request string. I know this isn't the optimal solution, but I really just want to get this up and running.
If I have a class, something like this
public class Data
{
public int a { get; set; }
public int b { get; set; }
}
public class RequestViewData
{
public IList<Data> MyData { get; set; }
}
I thought I could bind the MVC route to a web request like this
http://localhost:8080/Request?MyData[0].a=1&MyData[0].b=2&MyData[1].a=3&[MyData[1].b=4
But all this does is create an array of two data objects without populating the values 1,2, 3 or 4.
Is there a way to bind complex objects arrays?