0

Exception of type 'System.OutOfMemoryException' was thrown:

at System.Text.StringBuilder.ToString() at System.Web.Util.HttpEncoder.JavaScriptStringEncode(String value) at System.Web.HttpUtility.JavaScriptStringEncode(String value, Boolean addDoubleQuotes) at System.Web.Script.Serialization.JavaScriptSerializer.SerializeString(String input, StringBuilder sb) at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember)
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember)
at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, SerializationFormat serializationFormat) at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)
at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)

json string that returned is big(more than 5MB), what are the solution for this problem?

M. Adeel Khalid
  • 1,786
  • 2
  • 21
  • 24
Natans
  • 1

1 Answers1

0

By default, it is possible to send or receive 4MB of data(Maximum). If you want to send more than that, you have to change the maxMessageLength in your web.config file like below.

 <configuration>

  <system.web>

     <httpRuntime maxMessageLength="409600"

       executionTimeoutInSeconds="300"/>

 </system.web>

</configuration>

With above setting, you can send 400MB of data with maximum time of 300 seconds. After that time, your execution will get stopped as TimeOut.

CodingYoshi
  • 25,467
  • 4
  • 62
  • 64
  • 1
    @CodinngYoshi: Server Error in '/' Application. Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Unrecognized attribute 'maxMessageLength'. Note that attribute names are case-sensitive. Source File: D:\wgd\web.config Line: 40 Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1586.0 – Natans Feb 12 '17 at 10:29