0

I have written an mvc action that works in Chrome and Firefox but not in IE11. Using IE11 it returns a 404 response code.

Controller:

[HttpDelete]
public ActionResult DeleteAction(int ActionID)
{
    return Json(_Logic.DeleteAction(ActionID), JsonRequestBehavior.DenyGet);
}

Calling JS:

Ajax_Proxy.DeleteAction = function (_actionID, successCallback, failureCallback) {
    return $.ajax({
        type: "DELETE",
        datatype: 'json',
        url: "/root/someurl/DeleteAction?ActionId=" + _actionID,
        contentType: 'application/json; charset=utf-8',
        success: function (data) { successCallback(_actionID, data); },
        error: function (data) { failureCallback(data); },
    });
};

The Url I am accessing is correct, as it works in other browsers. Has anyone seen this before?

Piotr Leniartek
  • 1,177
  • 2
  • 14
  • 33
DavidB
  • 2,566
  • 3
  • 33
  • 63
  • Not sure about IE11, but older versions (eg IE8) got a bit confused when a reserved word was used (eg `Ajax.Proxy.void = function` fails). While it's unlikely 'DeleteAction' is a reserved word (but who knows...), try changing the method name. Long shot. – freedomn-m Jun 08 '15 at 14:28
  • Thanks, but I have already changed the names and it had no effect – DavidB Jun 08 '15 at 14:32

2 Answers2

1

Beacuse you say that it works in Chrome and Firefox I assume you enabled PUT/Delete methods on the IIS?

If yes, I think this may be problem that some IE browsers doesn't support type: "DELETE" in Ajax calls. Maybe you are using compability mode to IE8 or something like that?

This problem was already mentioned on SO here: Problem with jQuery.ajax with 'delete' method in ie maybe you just discover that IE11 also doesn't support DELETE.

Another one good discusion Are the PUT, DELETE, HEAD, etc methods available in most web browsers?

Community
  • 1
  • 1
Piotr Leniartek
  • 1,177
  • 2
  • 14
  • 33
  • Not sure what the issue is but I have changed to a GET and it is working now. Thanks I think you were right about the DELETE not being fully supported – DavidB Jun 08 '15 at 14:51
0

Try this.

Ajax_Proxy.DeleteAction = function (_actionID, successCallback, failureCallback) {
return $.ajax({
    type: "DELETE",
    datatype: 'json',
    url: '@Url.Content("~/root/someurl/DeleteAction/")' + _actionID,
    contentType: 'application/json; charset=utf-8',
    success: function (data) { successCallback(_actionID, data); },
    error: function (data) { failureCallback(data); },
});

};

joaoeduardorf
  • 44
  • 1
  • 3