CORS Support within WCF REST Services

This guy saved my day. http://blogs.microsoft.co.il/blogs/idof/archive/2011/07.aspx I am going to place some of his notes here, just in case that web page dies some day. (I hate finding “Your answer is right HERE” links, and then the link is dead.) <behaviors> <endpointBehaviors> <behavior name=”webSupport”> <webHttp /> <CorsSupport /> </behavior> </endpointBehaviors> </behaviors> <extensions> <behaviorExtensions> <add name=”CorsSupport” … Read more

Can we create custom HTTP Status codes?

Yes, as long as you respect the class — that is, 2xx for success, 4xx for Client error, etc. So you can return custom 4XX error codes (preferably those that are unassigned) for your own application’s error conditions. To quote from [RFC 2616][1]: “HTTP status codes are extensible. HTTP applications are not required to understand … Read more

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

Your code is actually attempting to make a Cross-domain (CORS) request, not an ordinary POST. That is: Modern browsers will only allow Ajax calls to services in the same domain as the HTML page. Example: A page in http://www.example.com/myPage.html can only directly request services that are in http://www.example.com, like http://www.example.com/testservice/etc. If the service is in … Read more