Data Browser - Viewing Site  Sector 23 Code Bank Logged in as:  Guest  




           


Cannot post object to .NET
In Angular 1.5, attempted to post an object with property Columns of type List<some class> to a .NET 4.5 controller method. The object was converted to null.

Solution: Rename property to something else. Columns seems to be a reserved keyword.

WRONG:
{
Id: 0,
Columns: [{a:1}]
}
RIGHT:
{
Id: 0,
MyColumns: [{a:1}]
}

Issue #2: you cannot pass List<some class> to a .NET 4.5 controller method. The list will be corrupted. Instead create a wrapper class that contains the list and pass that.
WRONG:
Save(List<Something> somethings)
RIGHT:
Save(SomethingCollection somethings)
where SomethingCollection contains a property "List<Something>Details"

Issue #3: you cannot pass List<some class> to a .NET 4.5 controller method if you are using MVC4.0. It will work if you pass to an APIController method. Solution: Upgrade MVC to version 5.0.

Created By: amos 9/27/2016 4:47:48 PM
Updated: 2/1/2017 2:28:56 PM