asp.net web api multiple get methods code example

Example: adding 2 get methods in controller web api

[RoutePrefix("api/EmployeeApi")]
public class EmployeeApiController : ApiController
{
    //GET api/EmployeeApi
    [HttpGet]
    [Route("")]
    public List GetAllStudents() { ... }

    //GET api/EmployeeApi/EmailChange/foo/[email protected]
    [HttpGet]
    [Route("EmailChange/{studentName}/{email}")]
    public List EmailChange(string studentName, string email) { ... }

    //GET api/EmployeeApi/AddressChange/foo/China
    [HttpGet]
    [Route("AddressChange/{studentName}/{address}")]
    public List AddressChange(string studentName, string Address) { ... }
}

Tags:

Misc Example