Calling my WCF service from my client silverlight app, I sometimes get a ProtocolException:
The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8).
Normally, I can step into the WCF service code and see it build an object then return it in serialised form.
But when the request exceeds ~4MB (as reported by Fiddler2), breakpoints in the WCF service code are not hit, and the content of the response (where the serialised object should be) is the HTML for the standard HTML page you'd see if you browsed to the service - the one that looks like this:
I can make any request fail or succeed by randomly adding characters to strings within the request object graph, or trimming chunks off the graph, so I'm fairly confident this is about the size of the request.
I'd be really grateful if anyone could explain why the response contains HTML, and even more grateful if you can tell me how to fix it.
I'm using VS2010. My server side config is:
<httpRuntime executionTimeout="10800"
maxRequestLength="10240" />
...
<system.web>
<httpRuntime maxRequestLength="2147483647" />
</system.web>
...
<serviceBehaviors>
<behavior name="StandardServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
...
<binding name="BasicHttpBinding_SilverlightService"
useDefaultWebProxy="false"
transferMode="Streamed"
bypassProxyOnLocal="true"
receiveTimeout="00:20:00"
sendTimeout="00:20:00"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferPoolSize="2147483647">
<readerQuotas maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxDepth="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="None"/>
</security>
</binding>
And client-side I have:
<binding name="BasicHttpBinding_SilverlightService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
Update
I've also tried removing the name from the binding tag, as suggested by this post.