我已经通过几个网站建议解决这个问题,但我仍然无法摆脱它。
我的WebConfig:
<bindings>
<webHttpBinding>
<binding name="SecureBasicRest">
<security mode="Transport" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="svcBehavior">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="svcEndpoint">
<webHttp helpEnabled="true"/>
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="SvcContract.Authenticate" behaviorConfiguration="svcBehavior">
<endpoint binding="webHttpBinding" bindingConfiguration="SecureBasicRest"
behaviorConfiguration="svcEndpoint" name="webHttp"
contract="SvcContract.Authenticate" />
</service>
</services>
希望有人可以提供帮助。提前致谢!。
修改
我必须用这个工作 https://localhost:6188/Authenticate/Login?username=user&password=pass&ip=127.0.0.1
答案 0 :(得分:53)
将<serviceMetadata httpsGetEnabled="true"/>
更改为<serviceMetadata httpsGetEnabled="false"/>
。您告诉WCF使用https作为元数据端点,我看到您在http上公开您的服务,然后您在标题中收到错误。
如果您想使用HTTP建议,还必须设置<security mode="None" />
。
答案 1 :(得分:23)
您需要在服务器端启用https绑定。在这种情况下IISExpress。在解决方案资源管理器中选择网站项目上的属性(不是双击)。在属性窗格中,您需要启用SSL。
答案 2 :(得分:0)
在端点标记中,您需要包含属性address =“”
<endpoint address="" binding="webHttpBinding" bindingConfiguration="SecureBasicRest" behaviorConfiguration="svcEndpoint" name="webHttp" contract="SvcContract.Authenticate" />
答案 3 :(得分:0)
答案 4 :(得分:-1)
要使其工作,您必须替换此行代码
serviceMetadata httpGetEnabled="true"/>
http而不是https
和security mode="None" />