title: .Net 4.0 WCF with Membership services
body: <p>having an unexplained issue..</p>
  
  <p>Upgraded a working .Net 3.5 WCF service to 4.0 and immediately experienced this error:</p>
  
  <p>"<em>The message with Action 'http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</em>"</p>
  
  <p>The service is using wsHttpBinding using TransportWithMessageCredential, Message ClientCredentials=UserName; so it is using SSL for message encryption security and Membership services for user authentication.  We need tthis configuration because our business partners will be accessing this from out on the public internet.
  The binding reported by the service is :</p>
  
  <pre><code>  &lt;wsHttpBinding&gt;
       &lt;binding name="WSHttpBinding_IManageSCACFI" 
            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 ordered="true" inactivityTimeout="00:10:00"
                enabled="false" /&gt;
            &lt;security mode="TransportWithMessageCredential"&gt;
                &lt;transport clientCredentialType="None" 
                    proxyCredentialType="None" realm="" /&gt;
                &lt;message clientCredentialType="UserName" 
                    negotiateServiceCredential="true"
                    algorithmSuite="Default" 
                    establishSecurityContext="false" /&gt;
            &lt;/security&gt;
       &lt;/binding&gt;
   &lt;/wsHttpBinding&gt;
  </code></pre>
  
  <p>This is all running in a web application (Virtual Directory in IIS7 on Windows Server 2008.  The application pool has been reset to use the 4.0 CLR.  The problem occurs even with the simplest service contract method, which simply returns a string.</p>
  
  <ol>
  <li>I know the wcf requests are making it to the server, because we are using a custom Membershiop provider, and I have wired it up to write a log entry when it validates the credentials, and this log entry is being created.  </li>
  <li>I know it's not in the code cause the entire package works fine on the development box (Windows 7, but also IIS 7,) with the exact same bits and config settings. </li>
  <li>If I switch to Securitymode = "Transport", it works, but of course it is then defaulting to windows integrated security, instead of UserName (I don't understand why it is doing this, but it is, the membership services process is not getting hit.)</li>
  <li>We have completely rebuilt the entire web site and web application from scratch on the server and are still experiencing the same issue. </li>
  <li>The error message above is also what is reported in the WCF diagnostics trace log, and there is no more detailed information there to help with either.</li>
  </ol>
  
  <p>We have been pounding away at this with no success for a while.. Has anyone else experienced this issue?</p>