title: ASP.NET Web API Action Routing
body: <p>After a lengthy discussion in terms of how our API would need to behave due to limitations of the backend design, I'd like to have the following possibilities:</p>
  
  <pre><code>1. /students/251/employment &lt;--- allow GET, PUT, POST
  2. /students/251/employment/jobs &lt;--- allow GET only
  3. /students/251/employment/jobs/435 &lt;--- allow all verbs
  4. /students/251/employment/internships &lt;--- allow GET only
  5. /students/251/employment/internships/664 &lt;--- allow all verbs
  </code></pre>
  
  <p>These cases are working for GET requests.  I'm struggling when I try to do a PUT request for case #1 and #3:</p>
  
  <pre><code>Case #1 Error
    No HTTP resource was found that matches the request URI '/students/251/employment/221'.,
    No action was found on the controller 'Employment' that matches the name '221'.
  
  Case #3 Error
    The requested resource does not support http method 'PUT'.
  </code></pre>
  
  <p><strong>Here's an abridged version of my controller methods:</strong></p>
  
  <pre><code>public ApiEmploymentGetResult Get(long id) {            
    // code omitted
  }        
  
  [HttpGet]
  public IEnumerable&lt;ApiJob&gt; Jobs(long id) {
    // code omitted
  }
  
  [HttpGet]
  public IEnumerable&lt;ApiOwnVenture&gt; OwnVenture(long id) {
    // code omitted
  }
  
  public void Put(long id, MyModel model) {
    // breaks before getting here
  }
  </code></pre>
  
  <p>My routing looks like this, but I'm not sure it's quite right, even though the GETs are working.</p>
  
  <pre><code>context.Routes.MapHttpRoute(
    name: "V1/EmploymentApi",
    routeTemplate: "api/v1/Employment/{action}/{jobId}",
    defaults: new { controller = "Employment", jobId = RouteParameter.Optional, action = "Get" }
  );
  </code></pre>
  
  <p>Case #1 seems to be conflicting due to the framework expecting an action rather than the 221.  I'd like to be able to get all of these cases working.</p>