locked
Controller action never called [SOLVED] RRS feed

  • Question

  • User471849597 posted

    My controller action with two parameters is never called. Can anyone see what I'm doing wrong?

    URL: /api/JobTitle/1/55              (The arguments are 1 and 55.)

    ROUTE:                   (The parameters are oldDescription and newDescription.)

    config.Routes.MapHttpRoute(
            name: "With2Ids",
            routeTemplate:  "api/{controller}/{oldDescription}/{newDescription}"
        );

    CONTROLLER:             (The parameters match those in the route.)

    [HttpPost]
    public HttpResponseMessage UpdateJobTitle(string oldDescription, string newDescription)
    {...
    

    CALL FROM VIEW:

        $.ajax({
            url: updateUrl,
            type: 'POST',
            success: function (result) {
                window.location = "/Views/index.html";
            }
        });
    

    =========================

    I've added a custom route with two parameters with the same names are the controller-action parameters. But it never gets called. Any idea why? Thanks!

    Thursday, July 30, 2015 1:34 PM

Answers

  • User471849597 posted

    I was missing:     <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.min.js"></script>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 30, 2015 3:28 PM