WCF Web Service returns “Bad Request” error when invoked through Javascript

后端 未结 3 1766
悲哀的现实
悲哀的现实 2021-01-16 17:11

I am trying to make an ajax GET request to a WCF web service method through javascript. The request returns with a 400 \"Bad Request\" error everytime. But if I invoke the s

3条回答
  •  渐次进展
    2021-01-16 17:57

    Thanks for all the responses. Surprisingly enough, I managed to fix the error, but the solution was totally not what I was expecting. I had to add an additional attribute to the markup of the Service1.svc file:

    Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory

    I am not sure why this wasn't automatically added to the file when the project was built, but thats what did it. I am now able to invoke the Test method through the browser as well as through my AJAX request with no problem.

    Thanks again for everybody's help.

提交回复
热议问题