Search code examples
.netwcfweb-configiis-7.5

WCF and windows authentication not working


I cant get my WCF serve to windows authenticate

If I allow anonymous everything works, no errors.

I'm running .Net 3.5 on windows 2008 r2 standard SP1 IIS 7.5, if it matters VS 2010

I have used the WCF Service configuration editor to try and validate what I am doing, still no luck

I get the error after a decent wait 20-30 seconds

Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NotSupportedException: Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

my web.config is

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>

    <bindings>
      <basicHttpBinding>
        <binding name="AmjBasicHttpEndpointBinding">
          <security mode="None">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>

    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="SMS.Services.BEIMBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="SMS.Services.BEIMBehavior" name="SMS.Services.BEIM">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="AmjBasicHttpEndpointBinding"
          name="BeimServices" contract="SMS.Services.IBEIM">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>

  </system.serviceModel>

EDIT the error message is on the web page. http://Servername/Directory/pageName.svc


Solution

  • Well, it turns out:

    Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

    Read the message carefully, and you'll see that you need to enable Anonymous Authentication for the IIS application hosting the service. (In IIS configuration).