【发布时间】:2013-12-12 18:22:25
【问题描述】:
所以我有以下控制:
public class ItemQuery {
public int storeID { get; set; }
public int companyID { get; set; }
public string itemName { get; set; }
public string itemDescription { get; set; }
public string itemPLU { get; set; }
public string itemUPC { get; set; }
public int supplierID { get; set; }
public string partNumber { get; set; }
}
public class ItemController : ApiController {
public List<Item> FindItem([FromUri]ItemQuery query) {
return new List<Item>();
}
}
我正在尝试用这个请求来解决它:
http://localhost:43751/api/Item/Find?query[storeID]=1
它不起作用,但给了我这个错误:
The requested resource does not support http method 'GET'.
我该怎么办?这是我的路由信息,我还没有更改任何内容:
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
【问题讨论】:
标签: asp.net-mvc asp.net-web-api routing