Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET Model binder cannot bind collection of complex of object containing collections
    text
    copied!<p>I sumbmit folliwing json via an ajax call to the mvc controller. JSON contains one property which is just and <code>int</code>. and another property which is an collection of <code>objects</code> and that <code>object</code>s themselves have collection of <code>otherobject</code>s and the properties of <code>otherojbect</code> are promitive types. the thing is that if I sumbit just the second property of that <code>json</code> (collection of complex <code>object</code>s) model binder does a very good job and binds it to model but when i submit that collection of <code>object</code>s alongside with the primitive <code>int</code> model binder just binds <code>int</code> property and the seccond property is just empty collection. I use ext-js ajax call. I tried submiting json with <code>params</code> property and with <code>jsonData</code> property nothing seems to work ? what is the best solution to this problem. any help would be appriciated.</p> <pre><code>public class ModelToBind { public int IntParam { get; set; } public IEnumerable&lt;CompexObject&gt; ComplexObjectParam { get; set; } } public class CompexObject { public int AnotherIntProp { get; set; } IEnumerable&lt;AnotherComplexObject&gt; AnotherComplexObject{ get; set; } } public class AnotherComplexObject { // some primitive properties here } public JsonData DoSomething(ModelToBind model) { model.IntParam; // this property is binded model.ComplexObjectParam; // this is binded as empty collection } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload