我在我的 mvc 应用程序中使用了主干.js,我有一个场景,我必须将一个数组传递给我在 Rest API 中的 Post 方法。我正在尝试发送一系列模型,然后调用this.collection.create(model)
. 我试图将 Post 方法称为
var myArrayofModels = JSON.stringify(e.models);
this.collection.create(myArrayofModels );
这e.models
是一个模型数组,我将其转换为 json 并调用 Post 方法,我想像这样在 Post 方法上接收模型数组
public HttpResponseMessage Post(InsuranceAddressViewModel[] model)
{
return null;
}
但是我在 Post 方法中得到了空数组。我将模型数组转换为 json 的方法是好的还是必须做其他事情。我已经尝试了几个解决方案,但无法理解。