title: Ajax Post: 405 Method Not Allowed
body: <p>Within my API Controller called Payment, I have the following method:</p>
  
  <pre class="lang-cs prettyprint-override"><code>[HttpPost]
  public HttpResponseMessage Charge(Payment payment)
  {
      var processedPayment = _paymentProcessor.Charge(payment);
      var response = Request.CreateResponse(processedPayment.Status != "PAID" ? HttpStatusCode.ExpectationFailed : HttpStatusCode.OK, processedPayment);
      return response;
  }
  </code></pre>
  
  <p>In my HTML page I have:</p>
  
  <pre class="lang-js prettyprint-override"><code>$.ajax({
          type: "POST",
          contentType: "application/json; charset=utf-8",
          url: "http://localhost:65396/api/payment/charge",
          data: $('#addPayment').serialize(),
          dataType: "json",
          success: function (data) {
              alert(data);
          }
      });
  </code></pre>
  
  <p>Whenever I fire the POST, I get </p>
  
  <pre><code>"NetworkError: 405 Method Not Allowed - http://localhost:65396/api/payment/charge"
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p>Thank you.</p>
  
  <p>UPDATE</p>
  
  <p>Here's the routing information (default)</p>
  
  <pre class="lang-cs prettyprint-override"><code> routes.MapHttpRoute(
                  name: "DefaultApi",
                  routeTemplate: "api/{controller}/{id}",
                  defaults: new { id = RouteParameter.Optional }
              );
  
              routes.MapRoute(
                  name: "Default",
                  url: "{controller}/{action}/{id}",
                  defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
              );
  </code></pre>