RadEditor - Many EditorLinks, Error during serialization or deserialization using the JSON JavaScriptSerializer

4 posts, 0 answers
  1. Anthony Gianino
    Anthony Gianino avatar
    2 posts
    Member since:
    Jun 2005

    Posted 31 May 2014 Link to this post

    Hello,

    We are using RadEditor (2014.1.225.40) & are encountering a serialization error(below) when setting up a large number of EditorLink entries (15,000+)

    I know the 'right' answer is to NOT build up that much data to send to the browser, but I am looking to see if there is any short term workaround to try.


    Please note:
    We do ALREADY have an entry to setup the maximum in the web.config, but that does appear to apply to the editor instance - I'm guessing it has it's own instance.
    <system.web.extensions>
    <scripting>
    <webServices>
    <jsonSerialization maxJsonLength="2147483644"></jsonSerialization>
    </webServices>
    </scripting>
    </system.web.extensions>

    When I break on the error I see that in RadEditor.SerializeCollections, there is a _serializer instance that has a MaxJSONLength of 2097152.
    (see attached image serializerSetting.gif)
    Is there any config/small code change I can make to adjust that until I get a better fix in place?


    Full Error:
    Server Error in '/' Application.Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

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

    Source Error: 

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace: 

    [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) +532853
    System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, SerializationFormat serializationFormat) +66
    System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember) +153
    System.Web.Script.Serialization.JavaScriptSerializer.SerializeEnumerable(IEnumerable enumerable, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat) +127
    System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember) +1306
    System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember) +197
    System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat) +28
    System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, SerializationFormat serializationFormat) +66
    Telerik.Web.UI.RadEditor.SerializeCollections(IScriptDescriptor descriptor, JavaScriptSerializer jss) +912
    Telerik.Web.UI.RadEditor.DescribeComponent(IScriptDescriptor descriptor) +1258
    Telerik.Web.UI.RadWebControl.Telerik.Web.IControl.DescribeComponent(IScriptDescriptor descriptor) +10
    Telerik.Web.UI.ScriptRegistrar.GetScriptDescriptors(Control control) +119
    Telerik.Web.UI.RadEditor.GetScriptDescriptors() +26
    Telerik.Web.UI.RadWebControl.System.Web.UI.IScriptControl.GetScriptDescriptors() +10
    System.Web.UI.ScriptControlManager.RegisterScriptDescriptors(IScriptControl scriptControl) +128
    Telerik.Web.UI.RadWebControl.RegisterScriptDescriptors() +90
    Telerik.Web.UI.RadEditor.RegisterScriptDescriptors() +27
    Telerik.Web.UI.RadWebControl.Render(HtmlTextWriter writer) +84
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +128
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
    System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +10
    System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +128
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
    System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +10
    System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +128
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
    System.Web.UI.Control.Render(HtmlTextWriter writer) +10
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +128
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
    System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +128
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
    System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +128
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
    System.Web.UI.Control.Render(HtmlTextWriter writer) +10
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +128
    System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +216
    System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
    System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +53
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
    System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +128
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
    System.Web.UI.Control.Render(HtmlTextWriter writer) +10
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +128
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
    System.Web.UI.Page.Render(HtmlTextWriter writer) +29
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1386
  2. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 02 Jun 2014 Link to this post

    Hello Anthony,

    Investigating the described method I am unable to find an explicit setter of the maxJsonLength regarding the serializer of the RadEditor control. The described value is the default value that is set automatically by the JavaScriptSerializer class.

    It would be easier to investigate the described issue with a simple project, in which is demonstrated how the service is used to request the mentioned links and how is the RadEditor control involved in this scenario. 

    Regards,
    Ianko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Anthony Gianino
    Anthony Gianino avatar
    2 posts
    Member since:
    Jun 2005

    Posted 02 Jun 2014 in reply to Ianko Link to this post

    Hello,
    Appears I cannot upload a zip attachment here, but the project is simple:

    WebForms, 4.0, Classic pipeline.

    In the default aspx:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="RadEditorJavaScriptSerializer.Default" %>
    <%@ register tagprefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" %>
    <!DOCTYPE html>
     
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <telerik:RadEditor ID="Editor" Runat="server" Skin="WebBlue" Enabled="true"
                    ImageManager-MaxUploadFileSize="1048576"
                    MediaManager-MaxUploadFileSize="1048576"
                    DocumentManager-MaxUploadFileSize="1048576"
                    TemplateManager-MaxUploadFileSize="1048576"
                    FlashManager-MaxUploadFileSize="10485760"
                     
                />
        </div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
        </form>
    </body>
    </html>
    code behind:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
     
    namespace RadEditorJavaScriptSerializer
    {
        public partial class Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                Editor.Links.Clear();
                EditorLink productLink = new EditorLink("Products", "");
                SetupProductLinks(productLink, "startproduct");
                Editor.Links.Add(productLink);
            }
     
            private void SetupProductLinks(EditorLink parentLink, string tagName)
            {
                for (int i = 0; i < 35000; i++)
                {
                    var code = i.ToString("00000000");
                    parentLink.ChildLinks.Add(new EditorLink(code, tagName + "(" + code +")"));
                }
             
                 
            }
        }
    }

    web.config
    <?xml version="1.0"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      -->
    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.0"/>
        <httpRuntime/>
        <httpHandlers>
          <add path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" verb="*" validate="false"/>
          <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" verb="*" validate="false"/>
          <add path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" verb="*" validate="false"/>
          <add path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" verb="*" validate="false"/>
        </httpHandlers>
        <httpModules>
          <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
        </httpModules>
      </system.web>
      <system.web.extensions>
        <scripting>
          <webServices>
            <jsonSerialization maxJsonLength="2147483644"/>
          </webServices>
        </scripting>
      </system.web.extensions>
    </configuration>
  5. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 04 Jun 2014 Link to this post

    Hello Anthony,

    Indeed the exception is thrown, although the tool is not designed to show so much links and if such approach succeeds, the browser would freeze on showing so many child dom elements. 

    You can try the same by adding them via client-side logic and test it on your end:
    <telerik:RadEditor ID="Editor" runat="server" OnClientLoad="OnClientLoad">
    </telerik:RadEditor>
     
    <script type="text/javascript">
        function OnClientLoad(editor, args) {
            var editorLinks = editor.get_links();
                 
            for (var i = 0; i < 1000; i++) {
                editorLinks.push({ name: "name - " + i, href: "url", target: "_blank", childLinks: [] });
            }
        }
    </script>


    I can only make assumptions why so much links are needed in a non-hierarchically designed tool. If there is such a requirement I recommend implementing a Custom Dropdown and using client side AJAX techniques to populate the links safely end user friendly.

    Regards,
    Ianko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top