我想将一个对象传递给我的mvc控制器动作并返回一个值列表但是我遇到了一些困难,有谁能看到我出错的地方?
继承我的javascript
var model = { MainOrganisation : frmOrg.elements["Schedule_OrgId"].value,
ContractRefs: $.map($('#js_multiselect_to_1 option'), function (ele) { return ele.value; })
};
$.ajax({
type: 'GET',
dataType: 'json',
cache: false,
url: '/ReportScheduler/GetReportUsers',
data: model,
contentType: "application/json; charset=utf-8",
success: function (data, textStatus, jqXHR) {
//Do Stuff
$("#DailyInvoiceItems").html(data.Id);
},
error: function (jqXHR, textStatus, errorThrown) {
//Do Stuff or Nothing
}
});

这是我控制器上的动作方法
[HttpGet]
public async Task<JsonResult> GetReportUsers(ReportUserRequest request)
{
GetUserRequest userRequest = new GetUserRequest(request.MainOrganisation);
var userResponse = await this._userService.GetAllUsersForOrgAsync(userRequest);
return Json(userResponse.users, JsonRequestBehavior.AllowGet);
}
我传入的模型结构如下
public class ReportUserRequest
{
public int MainOrganisation { get; set; }
public List<string> ContractRefs { get; set; }
public ReportUserRequest()
{
this.ContractRefs = new List<string>();
this.MainOrganisation = 0;
}
}
ajax调用跳转到控制器动作但是当我检查对象时,只有MainOrganisation有一个值,列表为空,但是我已经检查了客户端,并且它填充了值,因此它们是&#39;失去了&#39;某处