title: "405 Method not allowed" - when using ASP.NET jQuery ajax POST
body: <p>I've searched through loads of different existing SO questions related to a similar issue, but I've not been able to find anything relevant to my issue.</p>
  
  <p>I have the following jQuery code:</p>
  
  <pre><code>$.ajax({
     url: "Index.aspx/DeclineRequest"
     , type: 'POST'
     , contentType: 'application/json; charset=utf-8'
     , dataType: 'json'
     , data: JSON.stringify({ RequestId: requestId })
  });
  </code></pre>
  
  <p>I'm using a very similar technique to POST data on another ASP.NET web application, and this works fine. However, this application is returning the following error:</p>
  
  <blockquote>
    <p>"NetworkError: 405 Method Not Allowed - <a href="http://localhost:57255/" rel="noreferrer">http://localhost:57255/</a>....."</p>
  </blockquote>
  
  <p>I can't find anything different about these 2 applications, so I'm confused as to why this isn't working.</p>
  
  <p>This only difference between these 2 applications which I can think of, is that the one that is working is .NET 2.0, and the one that isn't working is .NET 3.5.</p>
  
  <p>I've tried adding the following to my <code>web.config</code>, but I still get the same 405 error:</p>
  
  <pre><code>&lt;webServices&gt;
     &lt;protocols&gt;
       &lt;add name="HttpPost"/&gt;     
       &lt;add name="HttpPostLocalhost"/&gt;   
     &lt;/protocols&gt;      
  &lt;/webServices&gt;
  </code></pre>
  
  <p>How can I resolve this issue?</p>
  
  <p><strong>UPDATE (16:40):</strong> I've moved this application to IIS, and the 405 error is no longer being returned. Our development environment however is localhost only. Why would this only error on localhost?</p>