How to support both kinds of URLs
问题 I'd like to be able to call GET by both: /api/Test/Test/1 /api/Test/Test?id=1 public class TestController : ApiController { [HttpGet] public string Test(int id) { return "Test"; } } How to configure the route? I have the default: config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); This makes "/api/Test/Test?id=1" work but not "/api/Test/Test/1" I tried to add the attribute