title: HTTP CODE 405 (Method Not Allowed), When I sent POST data in ASP.NET WebAPI CORS
body: <p>Web.config</p>
  
  <pre><code> &lt;httpProtocol&gt;
    &lt;customHeaders&gt;
      &lt;add name="Access-Control-Allow-Origin" value="*" /&gt;
      &lt;add name="Access-Control-Allow-Headers" value="*" /&gt;
      &lt;add name="Access-Control-Allow-Methods" value="GET,POST,PUT,DELETE,OPTIONS" /&gt;
    &lt;/customHeaders&gt;
  &lt;/httpProtocol&gt;
  &lt;handlers&gt;
    &lt;remove name="WebDAV"/&gt;
    &lt;remove name="ExtensionlessUrlHandler-Integrated-4.0" /&gt;
    &lt;remove name="OPTIONSVerbHandler" /&gt;
    &lt;remove name="TRACEVerbHandler" /&gt;
    &lt;add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /&gt;
  &lt;/handlers&gt;
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>  [EnableCors(origins: "http://domain/api/Clients", headers: "*", methods: "*")]
  public class ClientsController : ApiController
  {
      private ParaNewnergyEntities db = new ParaNewnergyEntities();
  
      // GET: api/Clients
      public IEnumerable&lt;Client&gt; GetClient()
      {
          return db.Client.ToList();
      }
      [HttpPost]
      public IHttpActionResult PostClient(String Username, String Password)
      {
          Client c = new Client
          {
              Username = Username,
              Password = Password
          };
  
          db.Client.Add(c);
          db.SaveChanges();
          return Ok(c);
      }
  </code></pre>
  
  <p>WebApiConfig.cs</p>
  
  <pre><code>     public static void Register(HttpConfiguration config)
      {
          config.MapHttpAttributeRoutes();
          config.EnableCors();
  
          config.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/{controller}/{id}",
              defaults: new { id = RouteParameter.Optional }
          );
  
      }
  </code></pre>
  
  <p>Ajax</p>
  
  <pre><code>   var sendData={
              Username:"gx",
              Password:"gx"
          };
          $.ajax({
              url: "http://domain/api/Clients",
              type: "POST",
              data: sendData,
              success: function (d) {
                  $("#msg").html(d);
                  console.log(d);
              }
          });
  </code></pre>
  
  <p>Browser Error:</p>
  
  <pre><code>  POST http://domain/api/Clients 405 (Method Not Allowed)
  </code></pre>
  
  <p>I can get API by <strong>GET</strong> method. It is very weirdo that I can get response from API by <strong>POST</strong> method without <strong>Any Parameter</strong>. Otherwise, I just got http error 405.  </p>
  
  <p>In addition, I get http error 405 from DELETE and PUT method, too. Only GET and Option return httpcode 200. </p>