gpt4 book ai didi

c# - 添加 WCF 服务引用时,HTTP 请求被客户端身份验证方案 'Anonymous' 错误禁止

转载 作者:太空狗 更新时间:2023-10-29 23:51:23 25 4
gpt4 key购买 nike

我在尝试将服务引用添加到我的 winforms 应用程序时遇到问题。服务和应用程序都在同一个解决方案中,并且服务使用安装了默认 iisexpress 开发证书的 iisexpress。当我尝试添加服务引用时,我会看到找到服务的正常对话框,然后告诉我证书未由授权机构签名。我“确定”该消息,但随后收到此错误。

The HTTP request was forbidden with client authentication scheme 'Anonymous'.

web服务的web.config如下

  <appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Windows" />
<identity impersonate="false" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="WsHttpBindingConfig">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Certificate" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>

</bindings>
<protocolMapping>
<add binding="wsHttpBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true" />
</system.webServer>

</configuration>

编辑----------------

我在接受证书后还会弹出以下消息框。

“从该地址下载元数据时出错。请验证您输入的地址是否有效”

我也发现如果我改变

<protocolMapping>
<add binding="wsHttpsBinding" scheme="https" />
</protocolMapping>

<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>

然后我可以突然添加引用。为什么是这样?当然我需要它是 wsHttpsBinding 吗?

最佳答案

在你的配置中你有<transport clientCredentialType="Certificate" /> ,表示必须使用签名证书来验证客户端。为此,您需要拥有正确签名的证书。

尝试使用 <transport clientCredentialType="None" />规避或查看the various options查看哪一个适用于您的用例。

关于c# - 添加 WCF 服务引用时,HTTP 请求被客户端身份验证方案 'Anonymous' 错误禁止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20251134/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com