How does ASP.NET Web.api handle two methods with names starting with GET?

后端 未结 3 1438
情话喂你
情话喂你 2021-01-02 11:33

I am looking at the following tutorial from Microsoft. As per this tutorial,

In the first example, \"products\" matches the controller named Produc

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-02 12:04

    Adding an answer to reflect that the latest version of Web API supports [Route] attribute natively

    [Route("api/products")]
    public IEnumerable GetAllProducts(){}
    
    [Route("api/products/sold")]
    public IEnumerable GetSoldProducts(){}
    

提交回复
热议问题