【发布时间】:2012-09-28 08:11:57
【问题描述】:
我正在使用带有 ASP.NET MVC 的 Web Api,我对它很陌生。我已经在 asp.net 网站上浏览了一些演示,我正在尝试执行以下操作。
我有 4 个 get 方法,具有以下签名
public List<Customer> Get()
{
// gets all customer
}
public List<Customer> GetCustomerByCurrentMonth()
{
// gets some customer on some logic
}
public Customer GetCustomerById(string id)
{
// gets a single customer using id
}
public Customer GetCustomerByUsername(string username)
{
// gets a single customer using username
}
对于上述所有方法,我希望我的 web api 如下所示
- 列表获取() =
api/customers/ - 客户 GetCustomerById(字符串 ID) =
api/customers/13 - 列出GetCustomerByCurrentMonth() =
/customers/currentMonth - 客户GetCustomerByUsername(字符串用户名)=
/customers/customerByUsername/yasser
我尝试对路由进行更改,但由于我是新手,不太了解。
所以,请有人帮助我理解并指导我应该如何做到这一点。谢谢
【问题讨论】:
-
查看路由和操作过滤器
标签: c# asp.net-web-api asp.net-web-api-routing