C# 具有WsHttpBinding的WCF服务&;windows身份验证失败,出现匿名访问错误

C# 具有WsHttpBinding的WCF服务&;windows身份验证失败,出现匿名访问错误,c#,wcf,authentication,C#,Wcf,Authentication,你好。我在WCF中编写了一个使用消息级安全性的服务,该安全性设置为使用Windows身份验证。相关配置如下所示: <wsHttpBinding> <binding name="WsHttpBinding" closeTimeout="00:30:00" openTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="00:30:00" maxBufferPoolSize="2147483647"

你好。我在WCF中编写了一个使用消息级安全性的服务,该安全性设置为使用Windows身份验证。相关配置如下所示:

<wsHttpBinding>
    <binding name="WsHttpBinding" closeTimeout="00:30:00" openTimeout="00:30:00"
      receiveTimeout="00:30:00" sendTimeout="00:30:00" maxBufferPoolSize="2147483647"
      maxReceivedMessageSize="2147483647">
      <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"
        maxBytesPerRead="2147483647" />
      <security mode="Message">
        <message clientCredentialType="Windows" establishSecurityContext="true" />
      </security>
    </binding>
</wsHttpBinding>

即使使用此配置,我仍会收到上述错误。

IIS身份验证是传输安全性。您的客户端请求消息安全性,因此您需要禁用它。消息安全性将由WCF而不是IIS处理。

回答清晰简洁,谢谢。找不到一个解释来解释清楚。
<wsHttpBinding>
    <binding name="WSHttpBinding_IEAIEndpointService" closeTimeout="00:10:00"
      openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
      maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
        <security mode="Message">
          <message clientCredentialType="Windows" establishSecurityContext="true" />
        </security>
    </binding>
</wsHttpBinding>
client.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("Username", "Password", "DOMAIN");