我正在使用 JQuery 从 HTML 表中创建数据数组,我需要将这些数组传递给 ASP.NET MVC 4 中的控制器方法。
var data = {
InstallationControls: array_installationControl,
HardwareGUIDs: array_HardwareGUID,
InstallAppIDs: array_InstallAppID,
MACAddresses: array_MACAddress
};
$.ajax({
url: "@Url.Content("~/Home/ActivationManagement")",
type: "POST",
data: {data: data},
success: function(){
console.log('success!!');
}
})
public class MACAddress
{
public String Key { get; set; }
public String Value { get; set; }
}
public class MyViewModel
{
public List<MACAddress> MACAddresses { get; set; }
}
public ActionResult ActivationManagement(MyViewModel model)
{
List<MACAddress> listOfMacAddresses= model.MACAddresses;
}
但是我收到一个 NullReferenceException 说我的 listOfMacAddresses 对象为空。我做错了吗?谢谢