【发布时间】:2016-02-03 18:10:06
【问题描述】:
当我登录到 wcf localhost/Service1.svc 我得到错误:
主机上配置的身份验证方案(“基本”)不 允许在绑定“BasicHttpBinding”上配置的那些 ('匿名的')。请确保将 SecurityMode 设置为 Transport 或 TransportCredentialOnly。此外,这可能是 通过更改此应用程序的身份验证方案解决 通过 IIS 管理工具,通过 ServiceHost.Authentication.AuthenticationSchemes 属性,在 应用程序配置文件在 元素,通过更新绑定上的 ClientCredentialType 属性, 或通过调整 AuthenticationScheme 属性 HttpTransportBindingElement。
Web.Config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows" />
<customErrors mode="Off"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="BasicAuthHttpModule"
type="WCF_Customer_RentalObject.BasicAuthHttpModule, WCF_Customer_RentalObject"/>
</modules>
</system.webServer>
</configuration>
你知道我要做什么吗?
当我添加这个时:
<bindings>
<basicHttpBinding>
<binding> <!--Notice, no name attribute set-->
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
我收到另一个错误:
主机上配置的身份验证方案('Basic')不允许在绑定'BasicHttpBinding'上配置的身份验证方案 ('谈判')。请确保将 SecurityMode 设置为 Transport 或 TransportCredentialOnly。此外,这可能是 通过更改此应用程序的身份验证方案解决 通过 IIS 管理工具,通过 ServiceHost.Authentication.AuthenticationSchemes 属性,在 应用程序配置文件在 元素,通过更新绑定上的 ClientCredentialType 属性, 或通过调整 AuthenticationScheme 属性 HttpTransportBindingElement。
【问题讨论】:
-
是的,我读过,但我不知道如何在 web.config 中更改它
标签: c# wcf iis basic-authentication