title: POST / PUT route constrainst issue on Web API 2
body: <p>I came across this issue by accident. I have this route</p>
  
  <pre><code> config.Routes.MapHttpRoute(
                    name: "RecycleCenters",
                    routeTemplate: "api/cars/{id}",
                    defaults: new { controller = "rc", id = RouteParameter.Optional }
              );
  </code></pre>
  
  <p>and I have a controller like this </p>
  
  <pre><code>public class CarsController : ApiController
  {
      public IEnumerable&lt;Car&gt; Get() { ... }
      public HttpResponseMessage Get(int id)  { ... }
      public HttpResponseMessage Post(Car car)  { ... }
      public HttpResponseMessage Put(int id, Car car)  { ... }
      public HttpResponseMessage Delete(int id)  { ... }
  }
  </code></pre>
  
  <p>Basically what's happening is that my routing is allowing to make a POST request to an endpoint like this <strong>/api/cars/id</strong>, when it shouldn't because to create a new car the request should be to this endpoint <strong>/api/cars</strong></p>
  
  <p>I've found an answer for my issue in <a href="http://brockallen.com/2012/07/12/beware-the-default-webapi-route-with-post-requests-and-a-route-parameter/" rel="nofollow">this link</a> but I want to know if the newer version of Web API has something already built in to prevent this scenario, if so then how to use it?</p>
  
  <p>Thanks</p>