title: Web api Post call from ajax fails
body: <p>I have an web api wand I call it method in an ajax with POST method, sending the parameter as data . It gives me a 404 not found error.</p>
  
  <p>But when I pass the data in the query string , it works fine. Please help me fixing the matter and get it worked when calling the method with data in the body, not the query string.</p>
  
  <p><strong>Note : The web application and Web-api are running on different ports</strong></p>
  
  <p><strong>Sending a concrete type object in query string also does not work and received to web api as null</strong></p>
  
  <p>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="Content-Type, contentType, data" /&gt;
              &lt;add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" /&gt;
            &lt;/customHeaders&gt;
  &lt;/httpProtocol&gt;
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code> public class RiskController : ApiController
      {
  </code></pre>
  
  <p>method   </p>
  
  <pre><code>[HttpGet, HttpPost]
      public DashboardContainerViewModel GetDashboardContainer(string token)
      {
  </code></pre>
  
  <p>Ajax call</p>
  
  <pre><code>var postData = { token: priv.secToken };        
  
  $.ajax({
              type: 'POST',
              url: 'http://localhost:48060/api/Risk/GetDashboardContainer',
              dataType: 'json',
              contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
              data: postData,
              success: function (data) {
                  pub.dashboardHeader(data.Name);
                  var defaultTab = _.find(data.Dashboards, function (tab) {
                      return tab.IsDefault == true;
                  });
  </code></pre>
  
  <p>And I get POST <a href="http://localhost:48060/api/Risk/GetDashboardContainer" rel="nofollow noreferrer">http://localhost:48060/api/Risk/GetDashboardContainer</a> 404 (Not Found)</p>
  
  <p>Fiddler request headers</p>
  
  <pre><code>POST http://localhost:48060/api/Risk/GetDashboardContainer HTTP/1.1
  Host: localhost:48060
  Connection: keep-alive
  Content-Length: 142
  Pragma: no-cache
  Cache-Control: no-cache
  Accept: application/json, text/javascript, */*; q=0.01
  Origin: http://localhost:10452
  User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
  Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  Referer: http://localhost:10452/Authorised/DashBoard/DashBoard.aspx
  Accept-Encoding: gzip, deflate, br
  Accept-Language: en-US,en;q=0.9
  
  token=ETvgg0YH4sx9w%2FiQL5560S20Ja4jGix%2FiBTOFGpQCliYZVilmtKiXPbk30d8FTYbhUWyFqz8%2FqT1pmI0oY6rzDGQ7krL6d2fDKDKwJhfCNFXZxnv%2BPCUj5ki5eizdWOM
  </code></pre>
  
  <p>Fiddler response headers</p>
  
  <pre><code>HTTP/1.1 404 Not Found
  Cache-Control: no-cache, no-store
  Pragma: no-cache
  Content-Type: application/json; charset=utf-8
  Expires: -1
  Server: Microsoft-IIS/8.0
  X-AspNet-Version: 4.0.30319
  X-SourceFiles: =?UTF-8?B?QzpcRGVmYXVsdENvbGxlY3Rpb25cQ0FNTVNfUHJvZHVjdHNcX1JlbGVhc2VcMTQxMExSLUFNXFdlYiBTZXJ2aWNlXENBTU1TLlNBQVMuV2ViQVBJXENBTU1TLlNBQVMuSVJNV2ViQVBJXGFwaVxSaXNrXEdldERhc2hib2FyZENvbnRhaW5lcg==?=
  X-Powered-By: ASP.NET
  Access-Control-Allow-Origin: *
  Access-Control-Allow-Headers: Content-Type, contentType, data
  Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
  Date: Fri, 29 Jun 2018 05:47:22 GMT
  Content-Length: 215
  
  {"Message":"No HTTP resource was found that matches the request URI 'http://localhost:48060/api/Risk/GetDashboardContainer'.","MessageDetail":"No action was found on the controller 'Risk' that matches the request."}
  </code></pre>