私のアクションは整数値の配列を受け入れます:
public ActionResult ActionName(int firstParamId, int secondParamId, int[] contactIds)
以下のコードを使用していますが、選択した整数の配列が送信されません。
function btnSend_onclick() {
var firstParamId = 1;
var secondParamId= 2;
var selectedContactIds = [];
$('#ContactsListContainer input:checked').each(function() {
selectedContactIds.push($(this).val());
});
var params = {
firstParamId : firstParamId ,
secondParamId: secondParamId,
contactIds: selectedContactIds
};
$.get('/ControllerName/ActionName', JSON.stringify(params))
.done(function(data, status) {
alert("Data: " + data + "\nStatus: " + status);
})
.fail(function(data) {
debugger;
alert(data.responseText);
});
}
パラメータごとに以下のエラーが表示されます。
The parameters dictionary contains a null entry for parameter 'firstParamId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Actionname(Int32, Int32, Int32[])'
in 'AppNamespace.MvcUI.Controllers.ControllerName'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.<br>Parameter name: parameters
上記のコードの何が問題になっていますか?