0

I have a custom SharePoint 2013 Custom List. I have a column which is of type Multiple Lines of Text. In this column I am storing a very large string, which is essentially a serialized string with a combination of both XML and JSON. I am able to save this data successfully into that column.

Now, while trying to View the Item, I am getting the exception given below. But while editing the item, I am able to open the Edit Form without any exception. Similarly, everything shows up properly in the Default View also. The issue seems to be only with View Item form. Can anyone please help? I also tried to set/increase the Max Length of JSON to integer maximum value in web.config, but without any success.

Exception:

[InvalidOperationException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.]
     System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat)
    +131   System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, SerializationFormat serializationFormat) +57   Microsoft.SharePoint.WebControls.ClientFormManager.OnPreRender(EventArgs e) +225   System.Web.UI.Control.PreRenderRecursiveInternal() +155   System.Web.UI.Control.PreRenderRecursiveInternal() +240   System.Web.UI.Control.PreRenderRecursiveInternal() +240   System.Web.UI.Control.PreRenderRecursiveInternal() +240   System.Web.UI.Control.PreRenderRecursiveInternal() +240   System.Web.UI.Control.PreRenderRecursiveInternal() +240   System.Web.UI.Control.PreRenderRecursiveInternal() +240   System.Web.UI.Control.PreRenderRecursiveInternal() +240   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    +4090
4
  • Use a View Model to serialize only the required properties of your model – Hardik May 19 '16 at 10:20
  • Manually serialize the DataSourceResult – Hardik May 19 '16 at 10:20
  • Is below given solution works for you? – Hardik May 19 '16 at 12:13
  • This is OOTB. Hence I cannot apply these solutions. Anyway, thanks for your suggestions. – Ven May 23 '16 at 4:54
0

There are 3 solutions for this issue.

  1. Enable paging by calling the Pageable method
  2. Use a View Model to serialize only the required properties of your model.
  3. Manually serialize the DataSourceResult

For the second method, I mean to say that pass less properties of the model as possible, to reduce the data to process.

The source code of the third solution is :

public ActionResult Read([DataSourceRequest] DataSourceRequest request){var data = GetData();var serializer = new JavaScriptSerializer();var result = new ContentResult(); serializer.MaxJsonLength = Int32.MaxValue; // Whatever max length you want here result.Content = serializer.Serialize(data.ToDataSourceResult(request)); result.ContentType = "application/json";return result;}
0

This is an old post, but... I had the same issue:

  • Edit.aspx was working fine,
  • Disp.aspx was causing this error (found in ULS logs):

    "Application error when access /sites/xyz/Lists/Tasks/DispForm.aspx,
    Error=Error during serialization or deserialization using the JSON
    JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property."

What solved my problem was editing (the ootb) dispForm.aspx and changing the Webpart setting "CSR Render Mode" to Server Render.

Hope it helps...

0

In my situation it was the list view threshold limit. I increased the threshold limit to do some admin work and as soon as I did this I started receiving complains from users.

You probably have a lookup field that exceeds the default threshold limit. And this ends up creating a long JSON string.

Go to Central Administration>Manage web applications and click on the web application and select "Resource Throttling" under General Settings from the ribbon. List View Threshold: 5000 (Default) List View Threshold for auditors and administrators:20000 (Default) List View Lookup Threshold: 12 (Default)

Play with these numbers and try again.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.