title: WCF Authentication doesn't prompt for credentials
body: <p>I've created a test WCF app in which I'm trying to get Authentication to work, but it just runs my method and doesn't ask me to login / authenticate. Below is code snippets in my web.config in my WCF app:</p>
  
  <pre><code>&lt;bindings&gt;
         &lt;wsHttpBinding&gt;
             &lt;binding name="Binding1"&gt;
                 &lt;security mode="Message"&gt;
                     &lt;message clientCredentialType="UserName" /&gt;
                 &lt;/security&gt;
             &lt;/binding&gt;
         &lt;/wsHttpBinding&gt;
  &lt;/bindings&gt;
  
  &lt;serviceCredentials&gt;
           &lt;userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyAPI.Authorization, App_Code" /&gt;
  &lt;/serviceCredentials&gt;
  </code></pre>
  
  <p>My Authorization class:</p>
  
  <pre><code>public class Authorization : UserNamePasswordValidator
      {
          public override void Validate(string userName, string password)
          {
              if (null == userName || null == password)
              {
                  throw new ArgumentNullException();
              }
  
              if (!(userName == "test1" &amp;&amp; password == "1tset") &amp;&amp; !(userName == "test2" &amp;&amp; password == "2tset"))
              {
                  // This throws an informative fault to the client.
                  throw new FaultException("Unknown Username or Incorrect Password");
                  // When you do not want to throw an infomative fault to the client,
                  // throw the following exception.
                  // throw new SecurityTokenException("Unknown Username or Incorrect Password");
              }
          }
      }
  </code></pre>
  
  <p>My Service.svc.cs Class</p>
  
  <pre><code>public string Hello(string message)
  {
       return "You typed: " + message;
  }
  </code></pre>
  
  <p>Am I supposed to put some attribute above this method to require authentication or above the class?</p>
  
  <p>I have then created a Test Console Application, here is the code:</p>
  
  <pre><code>public static Test.Service1Client client = new Test.Service1Client();
          static void Main(string[] args)
          {
              Console.WriteLine(client.Hello("hello"));
              Console.ReadLine();
          }
  </code></pre>
  
  <p>This just outputs "You typed: hello" without asking for authentication. Here is snippets of my app.config:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
          &lt;bindings&gt;
              &lt;basicHttpBinding&gt;
                  &lt;binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
                      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                      maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                      useDefaultWebProxy="true"&gt;
                      &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                          maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
                      &lt;security mode="None"&gt;
                          &lt;transport clientCredentialType="None" proxyCredentialType="None"
                              realm="" /&gt;
                          &lt;message clientCredentialType="UserName" algorithmSuite="Default" /&gt;
                      &lt;/security&gt;
                  &lt;/binding&gt;
              &lt;/basicHttpBinding&gt;
          &lt;/bindings&gt;
          &lt;client&gt;
              &lt;endpoint address="http://MyServer/Service1.svc" binding="basicHttpBinding"
                  bindingConfiguration="BasicHttpBinding_IService1" contract="Test.IService1"
                  name="BasicHttpBinding_IService1" /&gt;
          &lt;/client&gt;
      &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>I would expect to have to set the login credentials before calling <code>client.Hello("hello")</code> by doing:</p>
  
  <pre><code>client.ClientCredentials.UserName.UserName = "test1";
  client.ClientCredentials.UserName.Password = "1tset";
  </code></pre>
  
  <p>But obviously not</p>
  
  <h1>Edit</h1>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
  
      &lt;system.web&gt;
          &lt;compilation debug="true" targetFramework="4.0" /&gt;
      &lt;/system.web&gt;
      &lt;system.serviceModel&gt;
          &lt;bindings&gt;
              &lt;wsHttpBinding&gt;
                  &lt;binding name="Binding1"&gt;
                      &lt;security mode="Message"&gt;
                          &lt;message clientCredentialType="UserName" /&gt;
                      &lt;/security&gt;
                  &lt;/binding&gt;
              &lt;/wsHttpBinding&gt;
          &lt;/bindings&gt;
          &lt;behaviors&gt;
              &lt;serviceBehaviors&gt;
                  &lt;behavior&gt;
                      &lt;serviceCredentials&gt;
    &lt;userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyAPI.Authorization, App_Code" /&gt;
  &lt;/serviceCredentials&gt;
                      &lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&gt;
                      &lt;serviceMetadata httpGetEnabled="true"/&gt;
                      &lt;!-- 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 --&gt;
                      &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
                  &lt;/behavior&gt;
              &lt;/serviceBehaviors&gt;
          &lt;/behaviors&gt;
          &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt;
      &lt;/system.serviceModel&gt;
      &lt;system.webServer&gt;
          &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
      &lt;/system.webServer&gt;
  
  &lt;/configuration&gt;
  </code></pre>