Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何为支持AJAX的WCF服务同时启用HTTP和HTTPS?_Ajax_Wcf_Https - Fatal编程技术网

如何为支持AJAX的WCF服务同时启用HTTP和HTTPS?

如何为支持AJAX的WCF服务同时启用HTTP和HTTPS?,ajax,wcf,https,Ajax,Wcf,Https,以下是我的配置设置,目前只允许HTTP: <system.serviceModel> <services> <service name="MyAjaxSvc"> <endpoint address="" behaviorConfiguration="MyAjaxSvcEndpointBehavior" binding="webHttpBinding" contract="MyAjax

以下是我的配置设置,目前只允许HTTP:

  <system.serviceModel>
<services>
  <service name="MyAjaxSvc">
    <endpoint address="" behaviorConfiguration="MyAjaxSvcEndpointBehavior"
              binding="webHttpBinding"
              contract="MyAjaxSvc" />
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="MyAjaxSvcEndpointBehavior">
      <enableWebScript />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
此服务可能会在我网站的任何页面上调用。有些页面是HTTPS,所以我想对其进行设置,以便可以使用任一协议调用AJAX服务。理想情况下,我希望我所有的AJAX服务调用都是HTTPS,但由于您不能混合协议,我将满足于允许使用当前页面使用的任何协议来调用服务。

在黑暗中拍摄:


您需要在通常显示的代码上方添加另一个声明的绑定,然后声明另一个端点。

非常好。我将第二次绑定的安全模式设置为“传输”,这一切都起了作用。谢谢