title: ASP.NET WebApi - Multiple GET actions in one controller
body: <p>I have <code>Users</code> controller and basic REST pattern is working just fine. However I need one additional pattern <code>users/{id}/usergroups</code> that will return all user groups for that user.</p>
  
  <p>What would be the best way to implement this since I imagine I will need similar routes on many more controllers. Just default ones are not enough...</p>
  
  <h2>Error</h2>
  
  <blockquote>
    <p>Multiple actions were found that match the request:
    Api.Models.Users.User GetUser(Int32) on type Api.Controllers.UsersController
    System.Collections.Generic.IEnumerable`1[Api.Models.Users.UserGroup] GetUserGroups(Int32) on type Api.Controllers.UsersController</p>
  </blockquote>
  
  <h2>Code</h2>
  
  <pre><code>// GET api/Users
  public IEnumerable&lt;User&gt; GetUsers()
  
  // GET api/Users/5
  public User GetUser(int id) // THIS IS CONFLICT 1
  
  // PUT api/Users/5
  public HttpResponseMessage PutUser(int id, User user)
  
  // POST api/Users
  public HttpResponseMessage PostUser(User user)
  
  // DELETE api/Users/5
  public HttpResponseMessage DeleteUser(int id)
  
  // GET api/Users/5/UserGroups
  public IEnumerable&lt;UserGroup&gt; GetUserGroups(int id)  // THIS IS CONFLICT 2
  </code></pre>
  
  <h2>Edit 1</h2>
  
  <p>I did what <em>amhed</em> suggested and it doesn't solve the issue.</p>
  
  <pre><code>// GET api/Users/5
  [HttpGet, ActionName("getuser")]
  public User GetUser(int id) // THIS STILL DOES NOT WORK
  
  // GET api/Users/5/UserGroups
  [HttpGet, ActionName("usergroups")]
  public IEnumerable&lt;UserGroup&gt; GetUserGroups(int id) // THIS WORKS
  
  // ROUTES
  config.Routes.MapHttpRoute(
      name: "DefaultApi",
      routeTemplate: "{controller}/{id}/{action}",
      defaults: new { id = RouteParameter.Optional, action = RouteParameter.Optional }
  );
  </code></pre>