I have created a web api with Individual User authentication. After user get registered his information is stored in 2 tables, his general information is stored in "AspNetUsers" table and his role is stored in "AspNetUserRoles" table. Now the problem is when I am trying to delete any user from the list, its not working.Here is the delete action:
[ResponseType(typeof(AspNetUser))]
[ActionName("EmployeeInfo")]
[DeflateCompression]
public IHttpActionResult DeleteEmployeeInformation(string Id)
{
AspNetUser AspNetUser = db.AspNetUsers.Find(Id);
if (AspNetUser == null)
{
return NotFound();
}
db.AspNetUsers.Remove(AspNetUser);
db.SaveChanges();
return Ok(AspNetUser);
}
and here is the ajax call:
function DeleteEmployeeInformations(recordID) {
jQuery.support.cors = true;
var id = recordID
$.ajax({
url: 'http://localhost:61115/api/EmployeeInformations/EmployeeInfo/' + id,
type: 'DELETE',
contentType: "application/json;charset=utf-8",
success: function (data) {
GetAllEmployeeInformations();
},
error: function (x, y, z) {
alert(x + '\n' + y + '\n' + z);
}
});
}
This action is working fine without asp.net identity but its not working when I am using asp.net identity. So what should I do? Thanks.