title: Cannot post to another domain using ajax despite having CORS enabled
body: <p>I'm using MVC.net and sending post data to my Web API 2 controller. I keep getting a 500 internal server error message.</p>
  
  <p>I am trying to post to another domain if that matters? I have 2 visual studio instances running, one acting as the client, the other as the server. I have enabled CORS.</p>
  
  <p>The GET works fine with this set up, but now I'm trying to post.</p>
  
  <p>My controller on the 'server' is</p>
  
  <pre><code>[HttpPost]
  [Route("api/cms/")]
  public IHttpActionResult Post([FromBody]int accountId, [FromBody]string content, [FromBody]string paneId, [FromBody]string url)
  {
      //content
  }
  </code></pre>
  
  <p>The javascript on the 'client' I'm using is </p>
  
  <pre><code>function ajaxStart(type, url, data, successDelegate, failDelegate, errorDelegate) {
      $.ajax({
          type: type.toUpperCase(),
          url: url,
          contentType: "application/json;charset=utf-8",
          data: data,
          dataType: "json",
          success: function (response) {
              successDelegate(response);
          },
          failure: function (e) {
              failDelegate(e.statusText);
          },
          error: function (e) {
              errorDelegate(e.statusText);  //always hit
          }
      })
  }
  </code></pre>
  
  <p>The data is created with (I've purposely used nonsense strings just to ensure there is nothing wrong with the formatting)</p>
  
  <pre><code>var data = JSON.stringify({ accountId: 1, paneId: "_selectedPaneNumber", url: "_url", content: "content" });
  </code></pre>
  
  <p>And the 'header' view in Google Chrome Dev Tools shows:</p>
  
  <p><a href="https://i.stack.imgur.com/ySq9W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ySq9W.png" alt="enter image description here"></a></p>
  
  <p>I have no idea what I've done wrong.</p>