除了接收地址的子集合之外,该代码是否有效?在 json 中发送这个集合的正确方法是什么?不幸的是,这次尝试失败了。'addresses' 值为 null 谢谢,
var val = {
'forename': 'test',
'surname': 'test',
'postcode': 'test',
'Addresses': {
'Line1': 'Test',
'Line2': 'Here'
}
};
jr.ajax.loadJson(url, val,
true,
function(xhr, textStatus, errorThrown) {
},
true, 'post', val);
});
// I want the posted value to be this object
public class Member
{
public string forename { get; set; }
public string surname { get; set; }
public string postcode { get; set; }
public Address[] Addresses { get; set; }
}
public class Address
{
public string Line1 { get; set; }
public string Line2 { get; set; }
}
我的控制器如下所示:
public ActionResult Show(Member request) {..}