我想提供一个带有过滤器参数的GetAll api,如下所示:
/api/v1/location/amsterdam/order/?filter=x
但是这条路线:
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/v1/location/{location}/{controller}/{id}",
defaults: new { id = RouteParameter.Optional}
);
和这个网址:
/api/v1/location/amsterdam/order/?filter=x
我得到一个例外:
“未在与请求匹配的控制器'订单'上找到任何操作。”
'order'控制器有以下方法:
public HttpResponseMessage Get(int id)
public IQueryable<OrderDTO> Get(string filter)
public HttpResponseMessage Get()
当我从路线和网址({location}
)中移除/api/v1/location/order/?filter=x
段时,{strong> 的请求与Get(string filter)
方法匹配。
我做错了什么?这样做的正确方法是什么?
答案 0 :(得分:0)
尝试使用
/api/v1/location/amsterdam/order?filter=x
/
之前的?
无效。