Search code examples
c#ajaxasp.net-mvcektron

ajax call to c# mvc sends both post and get


I've looked at several solutions for making an ajax call and by not this issue mentioned anywhere i feel it might be something specific to the environment i'm working with. My controller:

    [HttpPost]
    public ActionResult ChangeDefualtCC(string a)
    {

        return Json("ok");
    }
    [HttpGet]
    public ActionResult ChangeDefualtCC()
    {

        return Json("ok");
    }

JS:

    $("nevermind").change(function () {

    $.ajax({
        type: "POST",
        url: "/Account/ChangeDefualtCC",
        dataType: "json",
        data: {
            a: "A"
        },
        success: function (data) { console.log(data)},
        error: function (data) { console.log("error");}
    });
});

The Controller code is never hit, and this is what i'm seeing in chrome after the ajax call:

EDIT 2: The page hits the [HttpGet] method.

chrome network tab

EDIT: I tagged Ektron as well because it is used in the project, and it is possible that it is affecting the call.

My Routes: mvc routes

Update: I have tried using Get, as well as Post, and also returning back to the View I was in, I get the 302 everytime.

any ideas?


Solution

  • Our project is integrated with the CMS Ektron. We later discovered that Ektron is hit before the C# code, and has some affect to any url without a trailing url.

    Thanks for all the help