Reputation: 22926
My ASP.NET server is providing a set of WCF services which are consumed by my WPF client. Everything was working just fine until the length of a string field exceeded 8K. This now generates the following exception on the ASP.NET server...
There was an error deserializing the object of type Project.ModelType. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.
I have increased the value of the MaxStringContentLength to be 64K on the WPF app.config but this has not solved the issue. So I guess I need to increase this value on the ASP.NET side as well. But I do not have any values in the web.config to change! Here is my web.config to show this...
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms name=".ASPXFTOAUTH"
timeout="10"
slidingExpiration="true"
cookieless="UseCookies"/>
</authentication>
<membership>
<providers>
<clear/>
</providers>
</membership>
<customErrors defaultRedirect="~/Error.htm" mode="RemoteOnly">
<error statusCode="404" redirect="~/404.aspx" />
</customErrors>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
So how do I update the server to indicate the higher MaxStringContentLength value? The app.config for my service looks like this...
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAccess" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="131072" maxBufferPoolSize="524288" maxReceivedMessageSize="131072"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="65536" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IAccess"
contract="AccessService.IAccess"
name="BasicHttpBinding_IAccess" />
</client>
</system.serviceModel>
Any ideas?
UPDATE:
My services are defined by having a class 'Access.svc'
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Access : IAccess
{
// ...IAccess method implementations
}
...which has the following markup...
<%@ ServiceHost Language="C#" Debug="true"
Service="Ecotech.AMS.WebServer.Access"
CodeBehind="Access.svc.cs" %>
...there is nothing specific about the service in the web.config, as noted in comments.
Upvotes: 0
Views: 479
Reputation: 222582
The place where you need to work on is the web config, you need to add service behaviours where you can set the size of data. For example like this,
<behaviors>
<serviceBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
if that does not work, post your web config here.Hope it helps.
Upvotes: 0
Reputation: 6249
Try clicking "Add Service Reference" via the right-click menu of your Project. Doing it this way will add the necessary configuration information into your web.config file.
Once you do this, you can set the maxReceivedMessageSize
property on your binding. Doing it this way will most accurately reflect what you are doing on the WCF service side of things.
Upvotes: 0