Reputation: 171
When I am serializing using JavaScriptSerializer in wcf service it gives me below error for defined code.
Code:
DataCollection<Entity> detailqueryentityCollection = _serviceProxy.RetrieveMultiple(detailquery).Entities;
if (detailqueryentityCollection.Count > 0)
{
listdata = new JavaScriptSerializer().Serialize(detailqueryentityCollection);
}
Error:
Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
I also add below code in web.config but it doesn't work.
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="500000000"/>
</webServices>
</scripting>
</system.web.extensions>
Please suggest me any solutions.
Upvotes: 0
Views: 452
Reputation: 10889
When instantiating the class yourself, you need to add the value to the MaxJsonLength
property of the class:
var jss = new JavaScriptSerializer();
jss.MaxJsonLength = 500000000;
listData = jss.Serialize(detailqueryentityCollection);
Upvotes: 2