title: Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service
body: <p>I am using IIS V5.1. Integrated windows authentication</p>
  
  <p>I have a following web config:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;wsHttpBinding&gt;
          &lt;binding name="wsHttpEndpointBinding"&gt;
            &lt;security mode="Transport" /&gt;
          &lt;/binding&gt;
        &lt;/wsHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;services&gt;
        &lt;service behaviorConfiguration="DXDirectory.Service1Behavior"
          name="DXDirectory.DXDirectoryService"&gt;
          &lt;endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpEndpointBinding"
            name="wsHttpEndpoint" contract="DXDirectory.IDXDirectoryService" /&gt;
          &lt;endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration=""
            name="MexHttpsBindingEndpoint" contract="IMetadataExchange" /&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="DXDirectory.Service1Behavior"&gt;
            &lt;serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
    &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>When I choose to see svc file in browser it will show the following error:</p>
  
  <p>Exception:<br>
  Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service. </p>
  
  <p><strong>This error is removed when I remove the Mex endpoint.</strong></p>
  
  <p>But when I try to add the service reference in client application it gives the following error :</p>
  
  <p>the document at the url <a href="http://localhost/DXDirectory/DXDirectoryService.svc" rel="nofollow noreferrer">http://localhost/DXDirectory/DXDirectoryService.svc</a> was not recognized as a known document type.</p>
  
  <p>The error message from each known type may help you fix the problem:</p>
  
  <ul>
  <li>Report from '<a href="http://localhost/DXDirectory/DXDirectoryService.svc" rel="nofollow noreferrer">http://localhost/DXDirectory/DXDirectoryService.svc</a>' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.</li>
  <li>Report from 'DISCO Document' is 'There was an error downloading '<a href="https://hes-ashu.abc.com/DXDirectory/DXDirectoryService.svc?disco" rel="nofollow noreferrer">https://hes-ashu.abc.com/DXDirectory/DXDirectoryService.svc?disco</a>'.'.
  
  <ul>
  <li>The underlying connection was closed: An unexpected error occurred on a send.</li>
  <li>Authentication failed because the remote party has closed the transport stream.</li>
  </ul></li>
  <li>Report from 'WSDL Document' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.</li>
  <li>Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
  Metadata contains a reference that cannot be resolved: '<a href="http://localhost/DXDirectory/DXDirectoryService.svc" rel="nofollow noreferrer">http://localhost/DXDirectory/DXDirectoryService.svc</a>'.</li>
  </ul>
  
  <p>The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.</p>
  
  <p>The remote server returned an error: (401) Unauthorized.</p>
  
  <p>If the service is defined in the current solution, try building the solution and adding the service reference again.</p>