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.
I have the following jQuery code:
$.ajax({
url: "Index.aspx/DeclineRequest"
, type: 'POST'
, contentType: 'application/json; charset=utf-8'
, dataType: 'json'
, data: JSON.stringify({ RequestId: requestId })
});
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:
"NetworkError: 405 Method Not Allowed - http://localhost:57255/....."
I can't find anything different about these 2 applications, so I'm confused as to why this isn't working.
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.
I've tried adding the following to my web.config
, but I still get the same 405 error:
<webServices>
<protocols>
<add name="HttpPost"/>
<add name="HttpPostLocalhost"/>
</protocols>
</webServices>
How can I resolve this issue?
UPDATE (16:40): 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?
DeclineRequest
method? – HaightDeclineRequest
method is simply callingreturn "Hello World"
at the moment. I don't think this is the issue as typing any method name returns the same error. I've deliberately misspelt the method in some tests to check this. – Randle