Search code examples
c#restwcfiis-7.5

Issue with WCF REST Service by disabling Anonymous Authentication


The authentication schemes configured on the host ('IntegratedWindowsAuthentication') do not allow those configured on the binding 'BasicHttpBinding' ('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.

We have an WCF Rest Service Hosted on IIS 7.5 We are able to browse the service if the Anonymous Authentication is Enabled(in IIS).

But experiencing the above error message if the Anonymous Authentication on IIS is Disabled.

we are using the webHttpBinding and with binding with below definition

<binding name="ExternalServicesRestBinding" closeTimeout="10:01:00" openTimeout="10:01:00" receiveTimeout="10:10:00" sendTimeout="10:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
          </security>
        </binding>

with endpoint behavior as

 <behavior name="endpointBehaviourForRestService">
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <webHttp />
        </behavior>

Any suggestion or clues please, which you think may address the issue?

Thanks in advance.

Rajkumar.


Solution

  • I have faced similar issue in my application.

    I have issue with service behaviorConfiguration and name of that service. I have correct as below. This solved my issue.

    Example:

    <system.serviceModel>
        <services>
          <service behaviorConfiguration="ServiceBehavior" name="service_namespace.service_Class" >
    

    and another point is as you are implementing REST service, we need to add Factory="System.ServiceModel.Activation.WebServiceHostFactory" to .svc file. (you get an 'Endpoint not found' error, but the service works fine when you invoke it correctly anyway. As mentioned previously, I'm using a default Web.config with .NET 4.6 (Simplified WCF configuration), so I may yet need to add endpoint details for that to work again).

    Please check with your config settings & svc file.