locked
Controller naming dilemma RRS feed

  • Question

  • User1827553000 posted

    Hi all,

    I've dilemma about naming in Web API. Example:

    Action should return all users with specific role. How to name controller and how to name route on controller and action?

    [RoutePrefix("api/users")]
    public class UserController : ApiController
    {
    [Route("admins")]
    public IEnumerable<User> GetAdminUsers()
    {
    IEnumerable<User> list = null;
    list = UserManager.GetAdmins();
    return list;
    }
    }

    or

    [RoutePrefix("api/roles")]
    public class RoleController : ApiController
    {
    [Route("admins")]
    public IEnumerable<User> GetAdminUsers()
    {
    IEnumerable<User> list = null;
    list = UserManager.GetAdmins();
    return list;
    }
    }



    Monday, May 30, 2016 11:57 AM

Answers

All replies