-1

just see the scenario

 public class CustomerController : ApiController
 {
     public IEnumerable<Customer> GetCustomersByID(int id)
     {

     }

     public IEnumerable<Customer> GetCustomersByName(string name)
     {

     }

     public IEnumerable<Customer> GetCustomersByEmail(string strEmail)
     {

     }
 }

now tell me what i need to do as a result end user can call three get action by their name. how to handle this situation. thanks

Monojit Sarkar
  • 2,353
  • 8
  • 43
  • 94

1 Answers1

1

You can set route for each method. Such as:

 [Route("GetById/{id}")]
 public IEnumerable<Customer> GetCustomersByID(int id)
 {

 }

You can call it getbyid/3. More details web api routing

Also there is a question for this issue.

Community
  • 1
  • 1
afrikaan
  • 425
  • 5
  • 21