title: Consuming web service with c# and basic authentication
body: <p>I want to consume a web service with this code:</p>
  
  <pre><code>WebService.GenRelClient client = new WebService.GenRelClient();
  client.ClientCredentials.UserName.UserName = @"UserName";
  client.ClientCredentials.UserName.Password = @"Password";
  var response = client.returnString("test");
  </code></pre>
  
  <p>And my config looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;startup&gt;
      &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /&gt;
    &lt;/startup&gt;
    &lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding name="GenRelClientPortBinding"&gt;
          &lt;security mode="TransportCredentialOnly"&gt;
            &lt;transport clientCredentialType="Basic" /&gt;
          &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/basicHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
        &lt;endpoint
            address="http://ws.domain.com/GenRel/GenRel"
            binding="basicHttpBinding"
            bindingConfiguration="GenRelClientPortBinding"
            contract="WebService.GenRelClientPort"
            name="GenRelClientPort" /&gt;
      &lt;/client&gt;
    &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>The request is sent to the web service and the response is sent back with incorrect message about that it need <strong>Basic Authentication</strong> because the request was sent probably without credentials, so I don't know where is the mistake.</p>
  
  <p>Thank you for your help</p>