【问题标题】:The authentication schemes configured on the host ('Basic')主机上配置的身份验证方案(“基本”)
【发布时间】: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。

【问题讨论】:

标签: c# wcf iis basic-authentication


【解决方案1】:

1.建议的客户端配置:

<bindings>
  <basicHttpBinding>
    <binding name="basicEndpoint">
      <security mode="Transport" >
        <transport clientCredentialType="Basic"
                   proxyCredentialType="None"
                   realm="" />
      </security>
    </binding>
  </basicHttpBinding>

可能是mode="TransportCredentialOnly"&gt; 可以
但是&lt;transport clientCredentialType="Windows" /&gt; 可能不是最好的

2。通过凭据:

HelloServiceClient client = new HelloServiceClient();
client.ClientCredentials.UserName.UserName = userName;
client.ClientCredentials.UserName.Password = password;
String msg = client.SayHello(userName);

希望对你有帮助

【讨论】:

    猜你喜欢
    • 2013-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-29
    • 2016-02-21
    • 2018-07-03
    • 2017-12-04
    相关资源
    最近更新 更多