【问题标题】:How can i send a large array to MVC Controller如何将大型数组发送到 MVC 控制器
【发布时间】:2020-05-06 10:18:05
【问题描述】:

向 MVC 控制器发送长度大于 250 的数组时出现错误。它适用于数组长度小于 250 项的情况。

客户代码

function saveVD() {
    var arr = [];
    $.each($("#tablevd tbody tr"), function () {
        arr.push({
                invNo: $(this).find('td:eq(0)').html().trim(),
                invDate: $(this).find('td:eq(1)').html().trim()
            })
    })
    $.ajax({
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            type: 'POST',
            url: "@Url.Action("Absorb","My")",
            data: JSON.stringify({ 'arr': arr }),
            success: function (result) {
            },
            error: function () {
            }
        })
}

服务器代码

public class MyController : Controller
{
    [HttpPost]
    public JsonResult Absorb(CIVM[] arr)
    {
        return Json(true, JsonRequestBehavior.AllowGet);
    }
}
public class CIVM
{
    public string invNo { get; set; }
    public DateTime invDate { get; set; }
}

【问题讨论】:

标签: javascript arrays json ajax asp.net-mvc


【解决方案1】:

以下配置更改可能会对您有所帮助

<appSettings>
    <add key="aspnet:MaxJsonDeserializerMembers" value="150000" />
</appSettings>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-01
  • 1970-01-01
  • 2013-09-26
  • 1970-01-01
  • 1970-01-01
  • 2016-09-07
相关资源
最近更新 更多