So, I have an angularJS array and I want to pass it to ASP.Net MVC method and then store its data in a database.
The array looks like the following:
telephone = [{'id':'T1', 'contactN':'212-289-3824'}, {'id':'T2', 'contactN':'212-465-1290'}];
When I click on a button, it fires the following JS function:
$scope.updateUserContacts = function () {
$http.post('/Home/UpdateUserContacts', { contactsData: $scope.telephone })
.then(function (response) {
$scope.users = response.data;
})
.catch(function (e) {
console.log("error", e);
throw e;
})
.finally(function () {
console.log("This finally block");
});
}
My question is, how I can receive this array in my ASP.Net MVC? What the format that can be compatible with this array?
The below is an example of ASP.Net MVC method but I don't know what the type and/or how to receive the passed array??
[HttpPost] //it means this method will only be activated in the post event
public JsonResult UpdateUserContacts(??? the received array)
{
......
}