Post从Javascript到控制器的字符串列表列表

时间:2017-07-31 10:53:05

标签: javascript c# asp.net json asp.net-web-api

这是我尝试POST的JSON数据:

{
  "UploadText": [       
    [
      "Stamp Duty+Rgst",
      "Extra on actuals (approximately @ 5.9%)",
      "4.90%",
      "",
      "688,225",
      "",
      "",
      "688,225"
    ],
    [
      "share certificate",
      "250",
      "",
      "",
      "250",
      "",
      "",
      "250"
    ],
    [
      "Legal charges",
      "Lumpsum (Approx 10 - 20k)",
      "",
      "",
      "",
      "",
      "18,000",
      "18,000"
    ],
    [
      "TOTAL",
      "",
      "",
      "",
      "16,122,863",
      "",
      "5,564,372",
      "21,687,235"
    ]
  ]
}

这是我的控制器方法:

public void UploadText(UploadItem uploadItem)
        {

        }

这是实际的课程:

 public class UploadItem
    {
        public List<string[]> UploadText { get; set; }
    }

我正在尝试使用Angular发布数据并且请求发送正确。但是模型绑定没有正确发生。 UploadText内的UploadItem始终为NULL。如果我更改为List<List<string>>,它仍为NULL。我做错了什么?

1 个答案:

答案 0 :(得分:0)

在您的JSON更改中

"UploadText":

"uploadItem":

因为这是预期的参数,请看下面的内容:

public void UploadText(UploadItem uploadItem)