WCF service failed to start due to IIS server configuration

1 minute read

I’ve encountered a problem when I deploy a web service in a new environment. While I’ve used the same binary work correctly in another server.

Here is a error message:

System.ServiceModel.ServiceActivationException: The service cannot be activated due to an exception during compilation. 

The exception message is:

The authentication schemes configured on the host ('IntegratedWindowsAuthentication') do not allow those configured on the binding 'WSHttpBinding' ('Anonymous'). Please ensure that the SecurityMode is set to Transport or TransportCredentialOnly.

Additionally, this may be resolved by changing the authentication schemes for this application through the IIS management tool, through the ServiceHost.Authentication.AuthenticationSchemes property, in the application configuration file at the element, by updating the ClientCredentialType property on the binding, or by adjusting the AuthenticationScheme property on the HttpTransportBindingElement.

Then I had this error:

System.NotSupportedException: The authentication schemes configured on the host ('IntegratedWindowsAuthentication') do not allow those configured on the binding 'WSHttpBinding' ('Anonymous'). 

So I’ve found that it shouldn’t be a problem of my code, while it’s a problem of IIS configuration.

To check the configuration, you need to go to -> %systemroot%\System32\inetsrv\config

You can compare all the configurations between this server and another server where the service works in.

For me, it was a configuration problem in applicationHost.config. And I just need to activate the anonymous anthentication.

<location path="DEV.MARKET.Global">
        <system.webServer>
            <security>
                <authentication>
                    <anonymousAuthentication enabled="true" />
                    <windowsAuthentication enabled="true" authPersistNonNTLM="true" />
                </authentication>
            </security>
        </system.webServer>
    </location>

So the probme is solved!

Hoping this post can help others! :)

SUN Jiangong

SUN Jiangong

A senior .NET engineer, software craftsman. Passionate about new technologies.