且构网

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

对WCF Web服务的Ajax调用返回400错误请求

更新时间:2022-05-22 23:46:17

您需要将service部分添加到web.config文件中.除非您告诉主机,否则主机不知道您要使用 webHttpBinding .

You need to add service section to your web.config file. Host does not know that you want to use webHttpBinding unless you tell him.

<services>
  <service name="Service1">
    <endpoint address=""
              binding="webHttpBinding"
              contract="IService1" />
  </service>
</services>

下面的链接提供了在IIS中托管服务的详细说明(使用 wsHttpBinding ).您只需要使用 webHttpBinding 而不是 wsHttpBinding - http://msdn.microsoft.com/en-us/library/ms733766.aspx

Link below provides detailed instructions for hosting service in IIS (with wsHttpBinding). You just need to use webHttpBinding instead of wsHttpBinding - http://msdn.microsoft.com/en-us/library/ms733766.aspx