传递一个对象数组和一个ID、Javascript和C#
我有一个对象数组和一个id,我想通过$http post发送它,并在后端将它们保存在两个变量中。 学生是学生对象的数组,每个对象都有一些属性 JavaScript:传递一个对象数组和一个ID、Javascript和C#,javascript,c#,Javascript,C#,我有一个对象数组和一个id,我想通过$http post发送它,并在后端将它们保存在两个变量中。 学生是学生对象的数组,每个对象都有一些属性 JavaScript: $scope.students = []; // This is the array of objects $http({ url: 'api/students', method: 'POST', params:{ id: classId, students: $scope.students } }
$scope.students = []; // This is the array of objects
$http({
url: 'api/students',
method: 'POST',
params:{
id: classId,
students: $scope.students
}
})
C#
[HttpPost]
public ActionResult MethodName(int id,列出学生){
//待办事项
}
我想发送它并在后端捕获这两件事。
params
是get,只要使用它,数据就会如下:data:{id:classId,students:$scope.students}
?
[HttpPost]
public ActionResult MethodName(int id, List<Student> students){
//TODO
}