配置复杂路由不生效是由于优先级的关系,应该把默认路由放在最后。
config.Routes.MapHttpRoute( name: "DynamicApi", routeTemplate: "DataApi/{id}/{excute}", defaults: new { controller = "DataApi", action = "Excute" } ); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional } );