C# 登录尝试失败WCF错误

C# 登录尝试失败WCF错误,c#,asp.net,.net,wcf,wcf-binding,C#,Asp.net,.net,Wcf,Wcf Binding,场景是:我有两台台式机: WCF服务托管在ABC台式机上 在CDE桌面上创建的控制台应用程序 当我尝试使用console应用程序连接到WCF服务时,出现登录尝试失败错误 WCF服务(web.config) 控制台应用程序(.cs文件) 注意:控制台应用程序CS文件中使用的用户名和密码是ABC Desktop machine本地用户名和密码。我认为您缺少web服务上绑定的一些配置: <bindings> <wsHttpBinding> <binding nam

场景是:我有两台台式机:

  • WCF服务托管在ABC台式机上
  • 在CDE桌面上创建的控制台应用程序
  • 当我尝试使用console应用程序连接到WCF服务时,出现
    登录尝试失败
    错误

    WCF服务(
    web.config

    控制台应用程序(
    .cs
    文件)


    注意:控制台应用程序CS文件中使用的用户名和密码是ABC Desktop machine本地用户名和密码。

    我认为您缺少web服务上绑定的一些配置:

      <bindings>
    <wsHttpBinding>
      <binding name = "someNameForTheBinding">
        <security mode="Message">
          <message clientCredentialType="Windows"/>
        </security>
      </binding>
    </wsHttpBinding></bindings>
    
    
    

    您可以在控制台应用程序(app.config)中查看更多关于它的信息,请查看上面的代码(控制台应用程序(app.config))。您还需要将其添加到服务器上。
    <configuration>
         <system.serviceModel>
             <bindings>
                 <wsHttpBinding>
                     <binding name="WSHttpBinding_IIISHost" closeTimeout="00:01:00" 
                         openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                         bypassProxyOnLocal="false" transactionFlow="false"  
                         hostNameComparisonMode="StrongWildcard"
                         maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                         messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                         allowCookies="false">
                       <readerQuotas maxDepth="32" maxStringContentLength="8192" 
                                     maxArrayLength="16384" maxBytesPerRead="4096" 
                                     maxNameTableCharCount="16384" />
                         <reliableSession ordered="true" inactivityTimeout="00:10:00"
                             enabled="false" />
                        <security mode="Message"> 
                          <transport clientCredentialType="Windows" />
                          <message clientCredentialType="Windows" 
                                   negotiateServiceCredential="true" algorithmSuite="Default"
                                   establishSecurityContext="true" />
                         </security>
                     </binding>
                 </wsHttpBinding>
             </bindings>
             <client>
                 <endpoint address="http://yogeshpc/IISHost/IISHost.svc" 
                           binding="wsHttpBinding" 
                           bindingConfiguration="WSHttpBinding_IIISHost"  
                           contract="ServiceReference1.IIISHost"
                     name="WSHttpBinding_IIISHost">
                     <identity>
                         <dns value="localhost" />
                     </identity>
                 </endpoint>
             </client>
         </system.serviceModel>
     </configuration>
    
       static void Main(string[] args)
            {
                var d = new IISHostClient();
                d.ClientCredentials.Windows.ClientCredential.UserName = "YOGESH";
                //d.ClientCredentials.Windows.ClientCredential.Domain = "Workgroup";
                d.ClientCredentials.Windows.ClientCredential.Password = "abc@123";
                d.ClientCredentials.Windows.AllowNtlm = false;
                Console.WriteLine(d.add(30, 30));
                Console.ReadLine(); 
            }
    
      <bindings>
    <wsHttpBinding>
      <binding name = "someNameForTheBinding">
        <security mode="Message">
          <message clientCredentialType="Windows"/>
        </security>
      </binding>
    </wsHttpBinding></bindings>