title: ASP.Net MVC 4 WebAPI POST returns 404
body: <p>I've looked at the many similar issues posted but couldn't find a solution that worked for me. So the call to Get is working fine but call to POST returns 404. I created a simple WebAPI project (MVC 4).</p>
  
  <pre><code>public class CasesController : ApiController
  {
      [Inject]
      public ICaseManager CaseManager { get; set; }
  
      // GET api/cases
      public IEnumerable&lt;Case&gt; Get()
      {
          return CaseManager.ListCases();
      }
  
      // POST api/cases
      [HttpPost]
      public void Post([FromBody]Case objCase)
      {
  
      }
  }
  </code></pre>
  
  <p>So when I navigate to <code>http://localhost:34645/api/cases</code> I get the following:</p>
  
  <pre><code>[{"CaseID":1,"CaseCode":"one","CaseDescription":"case one"},{"CaseID":2,"CaseCode":"two","CaseDescription":"case two"}]
  </code></pre>
  
  <p>I created another project (ASP.Net) and have an html file within it with the following code:</p>
  
  <pre><code>&lt;script src="Scripts/jquery-2.0.3.js"&gt;&lt;/script&gt;
  &lt;script src="Scripts/jquery-2.0.3.intellisense.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
      function postData() {
          $.post('http://localhost:34645/api/cases', { "CaseID": 3, "CaseCode": "three", "CaseDescription": "case three" }).done(function (data) { alert("Success " + data); }).fail(function (xhr, textStatus, errorThrown) { alert("Error " + xhr.status); });
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Every time I click the button that invokes postData, I get an alert "Error 404".</p>
  
  <p>Here are my routes:</p>
  
  <p>Global.asax:</p>
  
  <pre><code>protected void Application_Start()
  {
      AreaRegistration.RegisterAllAreas();
  
      WebApiConfig.Register(GlobalConfiguration.Configuration);
      FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
      RouteConfig.RegisterRoutes(RouteTable.Routes);
      BundleConfig.RegisterBundles(BundleTable.Bundles);
  }
  </code></pre>
  
  <p>WebAPIConfig.Register:</p>
  
  <pre><code>public static class WebApiConfig
  {
      public static void Register(HttpConfiguration config)
      {
          config.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/{controller}/{id}",
              defaults: new { id = RouteParameter.Optional }
          );
  
          //RA: to get JSON
          var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t =&gt; t.MediaType == "application/xml");
          config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
  
      }
  }
  </code></pre>
  
  <p>RouteConfig:</p>
  
  <pre><code> public class RouteConfig
   {
      public static void RegisterRoutes(RouteCollection routes)
      {
          routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
          routes.MapRoute(
              name: "Default",
              url: "{controller}/{action}/{id}",
              defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
          );
      }
  }
  </code></pre>
  
  <p>Please advise.</p>