title: JQuery Ajax POST to Web API returning 405 Method Not Allowed
body: <p>So I have a jquery ajax request like this:</p>
  
  <pre><code>    function createLokiAccount(someurl) {
      var d = {"Jurisdiction":17}
  
          $.ajax({
                  type: "POST",
                  url:"http://myserver:111/Api/V1/Customers/CreateCustomer/",
                  data: JSON.stringify(d),
                  contentType: "application/json; charset=utf-8",
                  dataType: "json",
                  success: function(data){alert(data);},
                  failure: function(errMsg) {
                      alert(errMsg);
                  }
              });
      }
  </code></pre>
  
  <p>This is hitting my web api which is basically:</p>
  
  <pre><code>    [HttpPost]
      public CreateCustomer.Response CreateCustomer(CreateCustomer.Request request)
      {
          HttpContext.Current.Response.AppendHeader("Access-Control-Allow-Origin", "*");
      ...
  </code></pre>
  
  <p>Which when I call it in Chrome gives me:</p>
  
  <pre><code>OPTIONS http://myserver:111/Api/V1/Customers/CreateCustomer/ 405 (Method Not Allowed) 
  No 'Access-Control-Allow-Origin' header is present on the requested resource.      
  </code></pre>
  
  <p>When I do the POST request from Fiddler it includes "Access-Control-Allow-Origin: *" in the response header as it should, which would suggest the API is configured correctly, yet the (from Fiddler) the jquery request looks like:</p>
  
  <p>OPTIONS <a href="http://myserver:111/Api/V1/Customers/CreateCustomer/" rel="nofollow">http://myserver:111/Api/V1/Customers/CreateCustomer/</a> HTTP/1.1
  Host: myserver:111
  Connection: keep-alive
  Access-Control-Request-Method: POST
  Origin: <a href="http://localhost:6500" rel="nofollow">http://localhost:6500</a>
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36
  Access-Control-Request-Headers: accept, content-type
  Accept: <em>/</em>
  Referer: <a href="http://localhost:6500/Home/Replication?interval=1" rel="nofollow">http://localhost:6500/Home/Replication?interval=1</a>
  Accept-Encoding: gzip,deflate,sdch
  Accept-Language: en-US,en;q=0.8,en-GB;q=0.6,it-IT;q=0.4,it;q=0.2</p>
  
  <p>So why is my POST request getting turned into an OPTIONS request?</p>