U4-2251 - TreeDataService throws JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property

Created by Murray Roke 21 May 2013, 05:13:30 Updated by Sebastiaan Janssen 28 May 2013, 07:18:42

This exception occurs in the back office when expanding a node with 5000 children.

I have changed my web.config to increase the maxJsonLength, but it appears this web config setting does not affect the max length in this scenario. Explanation of the problem: http://stackoverflow.com/a/7207539 Related discussions on the forum: http://our.umbraco.org/projects/backoffice-extensions/ucomponents/questionssuggestions/20615 http://our.umbraco.org/forum/core/general/41052


System.InvalidOperationException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. 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.Serialization.JavaScriptSerializer.Serialize(Object obj) at umbraco.businesslogic.Utils.JSONSerializer.Serialize(Object obj) at umbraco.cms.presentation.Trees.XmlTree.ToString(SerializedTreeType type) at umbraco.cms.presentation.Trees.XmlTree.ToString() at umbraco.presentation.webservices.TreeDataService.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


Morten Christensen 22 May 2013, 13:12:19

Would it be possible to get a copy of the database? You can attach it to the issue and set Visibility to HQ so that its not publicly available.

Murray Roke 22 May 2013, 21:20:45

Unfortunately no, sorry, it contains sensitive information.

Murray Roke 22 May 2013, 22:51:37

I've posted a pull request to fix this https://umbraco.codeplex.com/SourceControl/network/forks/Myster/Umbraco/contribution/4788

perhaps Int.MaxValue is excessive, but where would you draw the line?

Sebastiaan Janssen 27 May 2013, 12:16:50

@Murray: First of all, I would recommend organizing your content a little better, it's going to be very hard for your editors to find anything in a list of 5000 items. As you will have noticed, it's also not very perfomant. :-) Second: I've changed added the code from your pull request manually as it takes about 20-25 minutes to clone and merge pull requests. In the future if you have small change, I'd much more appreciate a patch file, that way your name will show up in the commit history as well. :-)

Lastly, indeed, changing the value in the web.config did not work in my tests but the code change did override the max length. The solution is not ideal at the moment but should help for now. In v7 we'll be implementing something called Container Document Types which will allow you to manage these kinds of lists of children much easier.

Changeset f0bbde5f85d7

Murray Roke 27 May 2013, 21:24:28

Thanks, I'll do a patch next time, I was just blindly following codeplex instructions :-) you are right about that being a lot, the user won't be using the tree to manage them, but we also don't want it to not open if they do click it, also the tree tries to open when linking to the article from search or email.

Sebastiaan Janssen 28 May 2013, 07:18:42

@Murray You MIGHT have some luck setting up User Permissions in the Users section then, try disabling "Browse node" on the parent. Not sure if that inherits properly though, so you may see it open from search and email still. Worth a try though!

Priority: Show-stopper

Type: Bug

State: Fixed


Difficulty: Easy


Backwards Compatible: True

Fix Submitted:

Affected versions: 4.11.8

Due in version: 6.0.6, 4.11.9


Story Points: