Inside my asp.net webAPI mvc controller, the delete method passed in an object called contact exits equal to zero. I have checked my code everywhere and I can not understand the reason. I have an editing operation that works in a very similar way.
So what causes the contact object parameter inside the asp.net webapi method to be a null value?
I checked, as shown in the diagram, that the contact object inside the angular controller is not null before passing to the webapi removal method.

Here is my rest of the code
<div data-ng-controller="ContactDeleteController">
<form name ="deleteContact" data-ng-submit="saveDeleteContact()">
<div>
<label>First Name: </label>
<input required type="text" placeholder="Enter First Name" data-ng-model="contact.FirstName"/>
</div>
<div>
<label>Last Name: </label>
<input required type="text" placeholder="Enter Last Name" data-ng-model="contact.LastName"/>
</div>
<div>
<label>Email Address: </label>
<input required type="text" placeholder="Enter Email Address" data-ng-model="contact.EmailAddress"/>
</div>
<div>
<label>Cell Phone Number: </label>
<input required type="text" placeholder="Enter Phone Number" data-ng-model="contact.PhoneNumber"/>
</div>
<div></div>
<div>
<button class="btn btn-primary" type="submit">Delete</button>
</div>
</form>
</div>
var ContactDeleteController = function ($scope, $http, $location) {
var contactId = $location.absUrl().match(/\/Delete\/(.*)/)[1];
$http.get("/api/ContactWeb/" + contactId)
.then(function (response) {
$scope.contact = response.data;
});
$scope.saveDeleteContact = function () {
var con = $scope.contact;
$http.delete("/api/ContactWeb", con)
.then(function (response) {
$scope.contact = response.data;
});
window.location = "/Contact/Index";
};
};

source
share