title: ASP MVC controller action '404 not found' error when decorated with [HttpPost]
body: <p>I have a controller action method that works when it looks like this:</p>
  
  <pre><code>public ActionResult testMethod(int id)
  {
      //do something...
      //return something...
      return View();
  }
  </code></pre>
  
  <p>But when I specify that it should be a "Post" method, I get a '404 not found error':</p>
  
  <pre><code>[HttpPost]
  public ActionResult testMethod(int id)
  {
      //do something...
      //return something...
      return View();
  }
  </code></pre>
  
  <p>I have other controller action methods in the same controller - both POST and GET, and they work fine. But this one doesn't? What's going on? (I'm sure I'm missing something obvious here...)</p>
  
  <p>Update: 
  An ajax call requests the controller method:
      var id = 1;</p>
  
  <pre><code>$.ajax({
      url: '/indices/testMethod/',
      data: id,
      type: 'POST',
      success: function (data) {
          //Do something
      }
  });
  </code></pre>
  
  <p>I've also tried to test the method with Postman, making sure a POST request is sent. </p>
  
  <p>Update 2: 
  I've tried changing the parameter to id, and tried to make sure all method and url locations are capitalised to match, but without any effect.</p>
  
  <p>In Fiddler, I can see that actually a GET request is being made, even though I specify a POST request in the ajax call, so now I need to find out why the request ends up being sent as a GET instead of a POST.</p>
  
  <p>I also tried including an attribute route description, like this</p>
  
  <pre><code>    [HttpPost]
      [Route("indices/TestMethod/{id:int}")]
      public ActionResult TestMethod(int id)
  </code></pre>
  
  <p>And then tried the ajax call with a different url:</p>
  
  <pre><code>$.ajax({
      url: '/indices/TestMethod/1',
      data: id,
      type: 'POST',
      success: function (data) {
          var tr = 123;
          var yr = data;
          //Do something
      }
  });
  </code></pre>
  
  <p>With attribute routing on, and the paramter value in the URL, I see in Fiddler that first a POST request happens, which gets a 301 status error, but then a GET request is also made, which gets the 404 error. </p>
  
  <p>Update 3: 
  After more investigations I narrowed the problem definition down sufficiently that it made sense to open a new question, which can be found here:
  <a href="https://stackoverflow.com/questions/32893268/asp-mvc-jquery-ajax-post-request-does-not-call-controller-method-but-works-in">ASP MVC jQuery $.ajax POST request does not call controller method, but works in &quot;fresh&quot; MVC project</a></p>
  
  <p>The issue seems to be caused by Content Security Policy settings that were active for this project. </p>