简体   繁体   中英

serialization or deserialization using the JSON JavaScriptSerializer

I have create one json method for web service, in which method passed json object, in this object there is one list (which contain list of pdf, images). When call this method and passed pdf more than 1 Mb length, server not able to handle this request and give error with message pasted below:

Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

To resolved this issue, I have tried one solution like below. I have added below code in web config.

But using this I am not getting successful result. Please help me with this issue.

  <httpRuntime targetFramework="4.5" executionTimeout="2400" maxRequestLength="20000"/>            
<system.web.extensions>
<scripting>
  <webServices>
    <jsonSerialization maxJsonLength="2147483647"/>
  </webServices>
</scripting>

You may try this..

public ActionResult MyControllerAction()
{
  var jsonResult = Json(veryLargeCollection, JsonRequestBehavior.AllowGet);
  jsonResult.MaxJsonLength = int.MaxValue;
  return jsonResult;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM