Dead simple question, possibly not so simple answer. Posting JSON.
public void Post(Model1 model1, Model2 model2)
{}
model1 is populated but not model2 (null).
public void Post(Model2 model2, Model1 model1)
{}
Now, model2 is populated but not model1 (null).
Why?
Edit
The reason for two parameters? Model2 used to be referenced from Model1, but that didn't work. That's when I split them up.
Edit
Right. Thanks marcind for the answer to the question above. Now for the reason the original setup didn't work. I'm not the forms universe anymore. I post Json. If you have child objects in your model then post child objects in your json.
Given
class ProductEditModel {
public string Name {get; set;}
}
class UserEditModel {
public string User {get; set;}
public ProductEditModel Product {get; set;}
}
the following
{"user": "philip", "product.name": "barbie"}
is not going to work. You'd even get an error if you in js try and setup the sematic equivalent
{user: "philip", product.name: "barbie"}
Neither of the following work either, I don't know why they would:
{"user": "philip", "productname": "barbie"}
{"user": "philip", "product_name": "barbie"}
What does work and which should be obvious holding my profession is
{"user": "philip", "product": {"name": "barbie"}}
Please kick me.
Beware! The following will not work given corresponding edit to the model above.
{"user": "philip", "ProductEditModel": {"name": "barbie"}}