0

I know 405 is a CORS error, but my website is on the same server as the WCF web service.

jQuery .ajax() POST Request throws 405 (Method Not Allowed) on RESTful WCF

My website/service appears to have a different problem. The first call to the Web Service succeeds. It is only when the user makes a change to the data and the web service is called for the second time that the 405 error is called. This happens on localhost and when I publish to another server.

Here is the service:

 [OperationContract]
 [WebInvoke(UriTemplate = "MyService", Method = "POST", ResponseFormat =      WebMessageFormat.Json,
 RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
 ServiceResponse MyService(SimpleRequest request);

Thanks, Matt

Community
  • 1
  • 1
  • Is the second request any different from the first? If you only perform the second and not the first is it any different? my guess is the fact that it is second has nothing to do with your problem. You should look at the differences between the two requests to diagnose this problem. – Kevin B Mar 17 '14 at 22:15

1 Answers1

1

Make sure that you are sending right JSON. If it works first time, it should also work second time as well. Try changing BodyStyle:

BodyStyle = WebMessageBodyStyle.Bare

See this answer if it helps.

Community
  • 1
  • 1
Faizan Mubasher
  • 4,427
  • 11
  • 45
  • 81