title: WCF Service Client: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding
body: <p>I've got a WCF Service running on my local IIS server. I've added it as a service reference to a C# Website Project and it adds fine and generates the proxy classes automatically.</p>
  
  <p>However, when I try and call any of the service contracts, I get the following error:</p>
  
  <blockquote>
    <p><strong>Description:</strong> 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.</p>
    
    <p><strong>Exception Details:</strong> System.ServiceModel.ProtocolException:
    The content type text/html;
    charset=utf-8 of the response message
    does not match the content type of the
    binding (application/soap+xml;
    charset=utf-8). If using a custom
    encoder, be sure that the
    IsContentTypeSupported method is
    implemented properly. The first 1024
    bytes of the response were: '
         function
    bredir(d,u,r,v,c){var w,h,wd,hd,bi;var
    b=false;var p=false;var
    s=[[300,250,false],[250,250,false],[240,400,false],[336,280,false],[180,150,false],[468,60,false],[234,60,false],[88,31,false],[120,90,false],[120,60,false],[120,240,false],[125,125,false],[728,90,false],[160,600,false],[120,600,false],[300,600,false],[300,125,false],[530,300,false],[190,200,false],[470,250,false],[720,300,true],[500,350,true],[550,480,true]];if(typeof(window.innerHeight)=='number'){h=window.innerHeight;w=window.innerWidth;}else
    if(typeof(document.body.offsetHeight)=='number'){h=document.body.offsetHeight;w=document.body.offsetWidth;}for(var
    i=0;i  
  </blockquote>
  
  <p>I also have a console application which also communicates with the WCF Service and the console app is able to call methods fine without getting this error.</p>
  
  <p>Below are excerpts from my config files.</p>
  
  <p>WCF Service Web.Config:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
     &lt;services&gt;
        &lt;service name="ScraperService" behaviorConfiguration="ScraperServiceBehavior"&gt;
           &lt;endpoint address=""
                     binding="wsHttpBinding" 
                     bindingConfiguration="WSHttpBinding_IScraperService"
                     contract="IScraperService" /&gt;
           &lt;endpoint address="mex" 
                     binding="mexHttpBinding" 
                     contract="IMetadataExchange" /&gt;
           &lt;host&gt;
              &lt;baseAddresses&gt;
                  &lt;add baseAddress="http://example.com" /&gt;
              &lt;/baseAddresses&gt;
           &lt;/host&gt;
        &lt;/service&gt;
     &lt;/services&gt;
     &lt;bindings&gt;
         &lt;wsHttpBinding&gt;
             &lt;binding name="WSHttpBinding_IScraperService"
                      bypassProxyOnLocal="false" transactionFlow="false"
                      hostNameComparisonMode="StrongWildcard"
                      maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000"
                      messageEncoding="Text" textEncoding="utf-8"
                      useDefaultWebProxy="true" allowCookies="false"&gt;
                 &lt;readerQuotas 
                       maxDepth="2000000" maxStringContentLength="2000000" 
                       maxArrayLength="2000000" maxBytesPerRead="2000000"
                       maxNameTableCharCount="2000000" /&gt;
                 &lt;reliableSession 
                       enabled="false" ordered="true" inactivityTimeout="00:10:00" /&gt;
                 &lt;security mode="Message"&gt;
                     &lt;message clientCredentialType="Windows"
                              negotiateServiceCredential="true"
                              algorithmSuite="Default"
                              establishSecurityContext="true" /&gt;
                 &lt;/security&gt;
              &lt;/binding&gt;
            &lt;/wsHttpBinding&gt;
        &lt;/bindings&gt;
        &lt;behaviors&gt;
            &lt;serviceBehaviors&gt;
                &lt;behavior name="ScraperServiceBehavior"&gt;
                    &lt;serviceMetadata httpGetEnabled="true" /&gt;
                    &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
                &lt;/behavior&gt;
            &lt;/serviceBehaviors&gt;
       &lt;/behaviors&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>Website Project Service Client <code>Web.Config</code>:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
     &lt;bindings&gt;
        &lt;wsHttpBinding&gt;
            &lt;binding name="WSHttpBinding_IScraperService" 
                closeTimeout="00:01:00" openTimeout="00:01:00" 
                receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" 
                hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
                messageEncoding="Text" textEncoding="utf-8"
                useDefaultWebProxy="true" allowCookies="false"&gt;
                &lt;readerQuotas 
                    maxDepth="32" maxStringContentLength="8192" 
                    maxArrayLength="16384" maxBytesPerRead="4096" 
                    maxNameTableCharCount="16384" /&gt;
                &lt;reliableSession enabled="false"
                    ordered="true" inactivityTimeout="00:10:00" /&gt;
                &lt;security mode="Message"&gt;
                    &lt;transport clientCredentialType="Windows" 
                         proxyCredentialType="None" realm="" /&gt;
                    &lt;message clientCredentialType="Windows" 
                         negotiateServiceCredential="true"
                         algorithmSuite="Default" /&gt;
                &lt;/security&gt;
            &lt;/binding&gt;
         &lt;/wsHttpBinding&gt;
      &lt;/bindings&gt;
  &lt;client&gt;
          &lt;endpoint name="WSHttpBinding_IScraperService"
              address="http://example.com/ScraperService.svc"
              binding="wsHttpBinding" 
              bindingConfiguration="WSHttpBinding_IScraperService"
              contract="ScraperService.IScraperService" &gt;
             &lt;identity&gt;
                 &lt;servicePrincipalName value="host/FreshNET-II" /&gt;
             &lt;/identity&gt;
          &lt;/endpoint&gt;
       &lt;/client&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>This is my first attempt at creating a WCF so it's all very new. Any help is much appreciated.</p>