Web API Routing - Found a few actions matching your query

I got this route:

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

And these 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 a mail request:

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

Why do I always get a few actions that were found with a request error?

+7
source share
1 answer

I got this route:

What you showed is the route for MVC controllers. I hope you understand that the Web API controllers are a completely different matter. They have their own routes defined in ~/App_Start/WebApiConfig.cs .

So, make sure you add the {action} token to the 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}" ); 
+38
source

All Articles