这是我的代码:
public class SecurityController : ApiController
{
//GET api/Security/Current
public HttpResponseMessage GetCurrent(){
}
//POST api/Security/Login
public HttpResponseMessage PostLogin(LoginModel model){
}
}
public class OrdersController : ApiController
{
[ActionName("Default")] //GET api/Orders
public HttpResponseMessage Get(){
}
[ActionName("Default")] //GET api/Orders/2
public HttpResponseMessage Get(long id){
}
[ActionName("Default")] //POST api/Orders/
public HttpResponseMessage Post(Order order){
}
[ActionName("Default")] //DELETE api/Orders/2
public HttpResponseMessage Delete(long id){
}
[HttpPost] //POST api/Orders/2/PerformAction
public HttpResponseMessage PerformAction(long id, ActionMsg action){
}
}
//路由定义
config.Routes.MapHttpRoute("ActionApi", "api/{controller}/{action}");
config.Routes.MapHttpRoute("WithActionApi", "api/{controller}/{id}/{action}");
config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", new { id = RouteParameter.Optional, action = "Default" }, new { id = @"\d+" });
我的路由不工作。
No HTTP resource was found that matches the request URI
我的 API 控制器的正确路由定义是什么?谢谢!