I am trying to send 2 parameters to the controller from the View using an ajax call. This function worked earlier when I was only using 1 parameter but it no longer is working since I added a second.
Javascript with ajax:
function DeleteRole(roleId) {
var confirmation = confirm("Are you sure you want Delete this Role");
if (confirmation) {
$.ajax({
type: "POST",
url: '@Url.Action("Delete_Role", "Admin")',
dataType: 'json',
data: JSON.stringify({
roleId: roleId,
applicationId: $('#AppList').val()
})
}).success(function (response) {
if (response.success) {
alert(response.responseText);
$(".k-grid").data("kendoGrid").dataSource.read();
}else {
alert(response.responseText);
}
}).error(function() {
alert("Error on Deletion");
});
}
}
MVC - controller method(information isn't getting here at all)
[HttpPost]
public JsonResult Delete_Role(Guid rowId, Guid applicationId)
{
var users = new UserStore().ReadForAppRole(applicationId, rowId);
if (users.Any())
{
return Json(new { success = false, responseText = "Users's Currently Exist Within this Role" },
JsonRequestBehavior.AllowGet);
}
new RoleStore().RemoveRole(applicationId, rowId);
return Json(new { success = true, responseText = "Role Successfully Deleted" },
JsonRequestBehavior.AllowGet);
}
rowIdvsroleIdthe variable names need to match also not sure what happens if a non valid guid is passed - think it may just come in as null[HttpDelete]?