Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
传递一个对象数组和一个ID、Javascript和C#_Javascript_C# - Fatal编程技术网

传递一个对象数组和一个ID、Javascript和C#

传递一个对象数组和一个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 } }

我有一个对象数组和一个id,我想通过$http post发送它,并在后端将它们保存在两个变量中。 学生是学生对象的数组,每个对象都有一些属性

JavaScript:

$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
}