Click here to Skip to main content
15,889,862 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
C#
config.Routes.MapHttpRoute(
    name: "With2Ids",
    routeTemplate:  "api/{controller}/{oldDescription}/{newDescription}"
);
(The parameters are oldDescription and newDescription.)

CONTROLLER:
C#
[HttpPost]
public HttpResponseMessage UpdateJobTitle(string oldDescription, string newDescription)
{...
(The parameters match those in the route.)

CALL FROM VIEW:
C#
$.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 as the controller-action parameters. But it never gets called. Any idea why? Thanks!
Posted
Updated 30-Jul-15 9:30am
v3

1 solution

I was missing:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900