小编h4c*_*ug5的帖子

Knockoutjs:将复杂类型发布到MVC控制器查询

我一直在与这场斗争3天.基本上,我有一个javascript对象发布到MVC控制器.在检查Request.Form.AllKeys namevalueCollection中的属性键名称时,我注意到我的子属性被[]包围,并且MVC模型绑定器不绑定这些值.

The values coming through on the controller look like this:

[6]: "Metadata[ScreenResolution]"
[7]: "Metadata[AudioCodec]"
[8]: "Metadata[VideoCodec]"
[9]: "Metadata[Format]"

My question is why is this happening. 
Edit: The "first-level properties are binding successfully, In the javascript, when the javascript object is being created, all the properties are being set correctly from KO"

MVC Model:

public class Movie
    {
        public int Id { get; set; }

        [Required]
        public string Name { get; set; }

        public string Directors { get; set; …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc knockout.js

1
推荐指数
1
解决办法
483
查看次数

标签 统计

asp.net-mvc ×1

c# ×1

knockout.js ×1