Your JSON data structure should match the structure of your C # classes, especially property names. So you need to send JSON that looks something like this:
{ Name: 'somename', LabeledEmail: { Labels: [ somelements ], Emails: [ someelements ] } }
So change your data: ko.toJSON(viewModel),
data: JSON.stringify({ Name: viewModel.Name(), LabeledEmail: { Labels: viewModel.EmailLabels(), Emails: viewModel.Emails() } })
Or just use the data in the same structure on both the client and the server ...
As a side note: in your C # models, to display the properties of an MVC model, you must have properties instead of fields so that:
public class User { public string Name { get; set; } public LabeledEmail LabeledEmail { get; set; } } public class LabeledEmail { public IList<ContactLabel> Labels { get; set; } public IList<ContactEmail> Emails { get; set; } }
source share