【发布时间】:2011-11-02 20:26:25
【问题描述】:
为什么 json 中的 3 级嵌套模型绑定不起作用?
使用 2 个级别进行测试,比如在 LevelTwo 上添加一个字符串属性,可以,但是 3 个级别不行吗?这是设计使然、错误还是我遗漏了什么?
客户端 jQuery 发布:
$.ajax({
url: "MyController/MyAction",
dataType: "json",
type: "POST",
cache: false,
data: {
Level1: {
Level2: {
StringValue: "Test"
}
}
}
});
服务器端模型:
public class MyForm
{
public LevelOne Level1 { get; set; }
}
public class LevelOne
{
public LevelTwo Level2 { get; set; }
}
public class LevelTwo
{
public string StringValue { get; set; }
}
【问题讨论】:
标签: json asp.net-mvc-3 model-binding