主机上配置的身份验证方案(';Basic';)不允许绑定上配置的那些方案';BasicHttpsBin
本文关键字:配置 方案 绑定 那些 不允许 BasicHttpsBin Basic 主机 身份验证 | 更新日期: 2023-09-27 18:29:13
我创建了一个WCF 4.5服务并进行了部署。该服务是第三方提供的另一个服务的门面。如果我启用匿名身份验证,我就可以访问我的服务,而且它运行良好。当我禁用匿名身份验证(只启用基本身份验证)时,我的服务无法进行身份验证。BTW:此服务器上的网页正在成功使用基本身份验证。
我看过SO的每一篇文章,都有类似的信息和问题,但没有一篇能成功解决。出现此错误:
主机上配置的身份验证方案("基本")不允许在绑定"BasicHttpsBinding"上配置的("匿名者")。请确保SecurityMode设置为Transport或TransportCredentialOnly。此外,这可能是通过更改此应用程序的身份验证方案解决通过IIS管理工具,通过ServiceHost.Authentication.Authentication Schemes属性,位于的应用程序配置文件元素通过更新绑定上的ClientCredentialType属性,或通过调整HttpTransportBindingElement。
Web.config(括号中的名称描述,而不是实际标签)
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<customErrors mode="Off" />
</system.web>
<system.serviceModel>
<client>
<endpoint
address="[HTTPS URL to 3rd-party service]"
binding="basicHttpBinding"
bindingConfiguration="[Configuration name of 3rd-party service]"
contract="[Contract of 3rd-party service"
name="[Name of 3rd-party service]" />
</client>
<services>
<service name="[Name of my service]">
<endpoint
address="[HTTPS URL to my service]"
binding="basicHttpsBinding"
bindingConfiguration="[Configuration name for my service]"
contract="[Contract name for my service]"
name="[Binding name for my service]" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="[Binding name for 3rd-party service]">
<security mode="Transport" />
</binding>
</basicHttpBinding>
<basicHttpsBinding>
<binding name="[Binding name for my service]">
<security mode="Transport">
<transport
clientCredentialType="Basic"
proxyCredentialType="None"
realm="[Realm for my service]" />
</security>
</binding>
</basicHttpsBinding>
</bindings>
<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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<security>
<authentication>
<basicAuthentication enabled="true" defaultLogonDomain="[Domain for my service]" />
<anonymousAuthentication enabled="false" />
</authentication>
</security>
<directoryBrowse enabled="false" />
</system.webServer>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="WarrantyReturnService" type="System.Diagnostics.TextWriterTraceListener" initializeData="D:'Temp'WarrantyReturnService.log" />
<remove name="Default" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
正如strictO1所指出的,问题是web.config和IIS设置不匹配。使这些相互一致解决了这个问题。