2
votes

I have changed Web.Config and the service is working with Anonymous Authentication. Though when Windows Authentication is enabled and Anonymous Authentication is disabled in IIS7.5, it starts giving me following error. Please help.

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

Web.config is as follows:

<?xml version="1.0"?>
<configuration>

<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
 <system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
 <system.serviceModel>
<bindings>
  <webHttpBinding>
    <binding name="JSONBinding"></binding>
  </webHttpBinding>
  <basicHttpBinding>
    <binding name="basicHTTP">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows"></transport>
      </security>
    </binding>
  </basicHttpBinding>
 </bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="basicBehavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>     
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="JSON">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
</behaviors>
<services>
<service name="RestWCFService.CalculationService" behaviorConfiguration="basicBehavior">
<endpoint address="" binding="basicHttpBinding" contract="RestWCFService.ICalculatorService" bindingName ="basicHTTP"></endpoint>
  <!--    
    <endpoint behaviorConfiguration="JSON" binding="webHttpBinding" bindingConfiguration="JSONBinding" contract="RestWCFService.ICalculatorService" name="JSONService"></endpoint>
  -->
  </service>      
</services>

<protocolMapping>
    <add binding="basicHttpBinding" scheme="http"/>
    <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>    
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"   />
 </system.serviceModel>
 <system.webServer>
 <modules runAllManagedModulesForAllRequests="true"/>
   <!--
    To browse web app root directory during debugging, set the value below to true.
    Set to false before deployment to avoid disclosing web app folder information.
    -->
  <directoryBrowse enabled="true"/>
 </system.webServer>

 </configuration>

Thanks in advance!!!

1

1 Answers

2
votes

You are not using your basic HTTP binding named basicHTTP in the endpoint. Change the attribute in your endpoint from bindingName="basicHTTP" to bindingConfiguration="basicHTTP".

By the way it could be that you have to enable both Anonymous Authentication and Windows Authentication in IIS.