【发布时间】:2012-09-22 05:02:29
【问题描述】:
我正在使用新的 MVC Web Api 我有这样的东西:
public class CustomersController : ApiController
{
public HttpResponseMessage Get()
{
//Return Somethings
}
}
我用 /api/customers 调用它
现在我希望能够按国籍和 id 进行过滤,所以我做了这个:
public class CustomersController : ApiController
{
public HttpResponseMessage Get(int Id, String Nat)
{
//and i filter here Return Somethings
}
}
如果我尝试使用/api/customers/1/us 它调用第一个方法,我知道这些是查询字符串,那么我如何定义路由以便我可以使用/api/customers/1/us?
【问题讨论】:
-
/api/customers/1/us 是嵌入值,而不是查询字符串。不幸的是,我不确定它为什么不调用重载的 Get。看看路线吧?
标签: c# asp.net-mvc asp.net-web-api