Sending an array of complex objects in the get string in C# ASP.NET MVC

Posted by Mr Snuffle on Stack Overflow See other posts from Stack Overflow or by Mr Snuffle
Published on 2010-04-27T13:41:02Z Indexed on 2010/04/27 13:43 UTC
Read the original article Hit count: 275

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc