首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >ASP.NET Web API中多个Get方法的路由

ASP.NET Web API中多个Get方法的路由
EN

Stack Overflow用户
提问于 2012-10-08 13:03:55
回答 10查看 145.6K关注 0票数 64

我正在使用Web和ASP.NET MVC,而且我对它非常陌生。我已经在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如下所示

Get用户名列表Get() = api/customers/

  • Customer用户名(字符串Id) = api/customers/13

  • List用户名()= /customers/currentMonth

  • Customer用户名(String GetCustomerById)= /customers/customerByUsername/yasser

我试着更改路由,但由于我是新手,无法理解太多。

所以,请有人能帮助我理解和指导我应该如何做。谢谢

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12775590

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档