8

I got this Route:

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { id = UrlParameter.Optional }
        );

And this Actions:

    [System.Web.Http.HttpPost]
    [System.Web.Http.ActionName("GetLoginSeed")]
    public object GetLoginSeed()

    [System.Web.Http.HttpPost]
    [System.Web.Http.AllowAnonymous]
    [System.Web.Http.ActionName("Authenticate")]
    public object PerformLogin(JObject jr)

This is the Post Request:

    http://localhost:61971/api/Login/GetLoginSeed

Why I always get an multiple actions were found that match the request error?

user229044
  • 232,980
  • 40
  • 330
  • 338
TheJoeIaut
  • 1,522
  • 2
  • 26
  • 59

1 Answers1

39

I got this Route:

What you have shown is a route for MVC controllers. I hope you realize that Web API controllers are an entirely different thing. They have their own routes defined in the ~/App_Start/WebApiConfig.cs.

So make sure tat you have included the {action} token in your Web API route definition (which I repeat once again has nothing to do with your MVC route definitions):

config.Routes.MapHttpRoute(
    name: "DefaultApi",
    routeTemplate: "api/{controller}/{action}"
);
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928