原因:由于默认路由没有匹配{action}
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
...
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
...
}
}
解决:
routeTemplate: "api/{controller}/{id}" 改为
routeTemplate: "api/{controller}/{action}/{id}",