ajax 将 int 列表传递给 asp net api 控制器,参数为空

ajax pass a list of int to asp net api controller, parameter is null

我想将一个 int id 列表传递到我的控制器中,但是当数据到达控制器操作时,参数为 null

  [HttpGet]
    public async Task<ActionResult> GetReport(int[] items)
    {
        var viewModel = await _reportLogic.GetReportByIdAsync(items);
       // return something;
    }

我的前端有这段代码

        $('#testPreviewList').click(function (e) {
        var items = new Array();
        $('.reportId').each(function () {
            items.push(this.id);
        });
        console.log(items);
        $.ajax({
            url: "/home/GetReport",
            type: "GET",
            //contentType: "application/json; charset=utf-8",
            data: { "items": items},
            dataType: "json",
            success: function (data) {
                //do something
                });
                $("#datos").html(row);
                $('#authorNameTextBox').val('');
            },
            error: function (result) {
                //alert("Error");
            }
        });
    });

我做错了什么?

谢谢

使用 POST 而不是 GET。 在ajax中使用繁体属性,设置为真。

$.ajax({ url: "/home/GetReport", type: "POST", //contentType: "application/json; charset=utf-8", data: { "items": items}, dataType: "json", Traditional: true, success: function (data) { //do something }); $("#datos").html(row); $('#authorNameTextBox').val(''); }, error: function (result) { //alert("Error"); } });