且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WCF Web服务返回“错误请求”通过Javascript调用时出错

更新时间:2023-01-17 12:12:55

感谢所有回复。令人惊讶的是,我设法修复了错误,但解决方案完全不是我所期待的。我必须在Service1.svc文件的标记中添加一个额外的属性:

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

Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory

我不确定为什么在构建项目时没有自动添加到文件中,但那就是它做了什么。我现在能够通过浏览器以及通过我调用Test方法AJAX请求没问题。

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.

再次感谢大家的帮助。