I'm using this Ajax code for deleting record. The code works fine in localhost whereas it continuously asks for credentials on hosted server.
and on windows
With all of the participants'suggestions, I mostly suspect now on two things.
1) The web hosting is a cheap shot and isn't updating for the Application rights despite several efforts (Needs to contact server level support)
2) Probably the message box is requiring some token for authentication like this
$(document).ready(function () {
$('.js-delete').on('click', function () {
var button = $(this);
var buttonId = button.attr("data-id");
//var container = $(this).parent().siblings('#tablex').find('#hiddenTable').clone();
var box = bootbox.dialog({
show: false,
message: "Are you sure you want to delete the Record?",
title: "Delete Record?",
buttons: {
cancel: {
label: "Cancel",
className: "btn-default"
},
ok: {
label: "Delete",
className: "confirm btn btn-danger",
callback: function (result) {
if (result) {
$.ajax({
url: "/api/datax/delete/" + button.attr("data-id"),
method: "Delete",
success: function () {
button.parents("tr").remove();
}
});
}
console.log('Button Pressed.');
}
}
}
});
});
});
And in my Controller, I'm handling this delete call like this.
[Route("api/datax/delete/{id}")]
public void Delete(int id)
{
var dataInDb = _context.Datax.SingleOrDefault(c => c.Id == id);
if (dataInDb == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
_context.Datax.Remove(dataInDb);
_context.SaveChanges();
}