Spell check hander error: The length of the string exceeds the value set on the maxJsonLength property

11 posts, 0 answers
  1. Suhua
    Suhua avatar
    6 posts
    Member since:
    Mar 2013

    Posted 25 Dec 2014 Link to this post

    I use client js method "startSpellCheck(); " to check spelling, it works fine when the text is small, but when the text content is large, for example 30k+ lines, an error page pop up:

     
    Spell Check handler server error: 500<br><br><title>...The length of the string exceeds the value set on the maxJsonLength property.</title><br>...


    I have set the maxJsonLength to a big value in web.config, but it seems that the spell check ignore the setting.
    ...

    <system.web.extensions><br>    <scripting><br>      <webServices>       <br>        <jsonSerialization maxJsonLength="2147483644"></jsonSerialization><br>      </webServices><br>    </scripting><br>  </system.web.extensions>

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 26 Dec 2014 Link to this post

    Hi Suhua,

    Please take a look at the following forum thread and help article, where you will find detailed information on the error that you are receiving and how to handle it:

    Hope this helps.



    Regards,
    Konstantin Dikov
    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. Suhua
    Suhua avatar
    6 posts
    Member since:
    Mar 2013

    Posted 29 Dec 2014 in reply to Konstantin Dikov Link to this post

    Hi Konstantin,

    Thanks for your response,  I have set maxRequestLength and maxAllowedContentLength to a bigger value in the web.config, but still show the same error message:
    Error during serialization or deserialization using the JSON JavascriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

    I also checked the string length which is sent for spelling check: 285478


  4. Suhua
    Suhua avatar
    6 posts
    Member since:
    Mar 2013

    Posted 29 Dec 2014 in reply to Konstantin Dikov Link to this post

    Hi, 

    To reproduce the issue, you can use below codes:

    function spellCheck() {
     
            //get spell check control
     
            var spellCheckID = $telerik.$("[id$='spellCheckRegisterTable']").attr("id");
     
            var spellCheckRegisterTable =
    $find(spellCheckID);
     
            if (spellCheckRegisterTable) {
     
                spellCheckRegisterTable.set_textSource(new checkTextSource());
     
                
    spellCheckRegisterTable.startSpellCheck();           
     
            }
     
        }
     
      
     
        function checkTextSource() {
     
            this.get_text = function () {
     
                
     
                    //for test
     
                    results =
    "";
     
                    for (var i = 0; i
    < 40000; i++) {
     
                        results += "testt<br>";
     
                    }
     
                    
    console.log(results.length);
     
                    //end test
     
                     return results;          
     
     
      
     
            }
     
            this.set_text = function (newText) {          
     
            }
     
        }

     <jsonSerialization maxJsonLength="2147483644"></jsonSerialization>
     <httpRuntime useFullyQualifiedRedirectUrl="false" requestLengthDiskThreshold="8192" maxQueryStringLength="2097151" requestValidationMode="2.0" targetFramework="4.5" maxRequestLength="1048576" executionTimeout="20000" />
    <requestLimits maxAllowedContentLength="1073741824" />

    Could help me on this? I need to fix this as soon as possible. thanks 

    Regards,

    Suhua
  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 05 Jan 2015 Link to this post

    Hi Suhua,

    Thank you for the sample.

    I have tested the code snippet that you have provided and I was able to replicate the same issue. It seems that this is a limitation of the JavaScriptSerializer:
    Nevertheless, I have located the code where a new instance of the JavaScriptSerializer is used and I log this as a feature request, so our developers team could investigate the possibility of setting the MaxJsonLength property to int.MaxValue for example or to the value set in the web.config. 

    Please excuse us for any inconvenience caused by this.


    Kind Regards,
    Konstantin Dikov
    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.

     
  6. Duncan
    Duncan avatar
    1 posts
    Member since:
    Dec 2015

    Posted 01 Dec 2015 in reply to Konstantin Dikov Link to this post

    I am having the same issue. Is there anyway to resolve this ? 
  7. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5324 posts

    Posted 01 Dec 2015 Link to this post

    Hello Duncan,

    This has not been implemented yet. I created the following page where you can track the progress of this item: http://feedback.telerik.com/Project/108/Feedback/Details/176735-radspell-should-use-the-maxjsonlength-value-specified-in-the-web-config.

    Regards,

    Marin Bratanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  8. Latheesh
    Latheesh avatar
    2 posts
    Member since:
    Jan 2012

    Posted 28 Apr in reply to Marin Bratanov Link to this post

    Hi Marin,

    Feedback portal says it has been completed, but has this been implemented (also for ASP.NET AJAX RadGrid) as well ?

    I am getting the same error with Virtualization enabled.

    Regards

    Latheesh

  9. Rumen
    Admin
    Rumen avatar
    14320 posts

    Posted 29 Apr Link to this post

    Hi,

    The reason for the serialization error in your Grid project is most likely due to that too much data is serialized at once.

    I suggest you try lowering the InitiallyCachedItemsCount on your end (set lower number - 1000 for example) which should help you overcome the maxJsonLength error:

    <Virtualization EnableVirtualization="true" InitiallyCachedItemsCount="1000" LoadingPanelID="ajaxLoadingPanel" ItemsPerView="100" />

    Please let me know in case you need additional assistance and please provide a simple repro project where we can see the error.

     

    Regards,
    Rumen
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  10. Latheesh
    Latheesh avatar
    2 posts
    Member since:
    Jan 2012

    Posted 29 Apr in reply to Rumen Link to this post

    Hi Rumen,

    Thank you for the reply.
    I had tested with InitiallyCachedItemsCount="1000" setting already. It does not satisfy my requirement since I need to cache 100k records(or at least 10k) initially in the grid.
    This is to avoid binding the 100k data again in the grid (with pagesize 1000) while navigating through pages. Every server call has to process the 100k records again(It's not a simple select) if I make a server data request which takes up 10s. So every page switch takes 10s or more.

    Please provide a specific workaround to achieve this requirement to cache the whole data initially itself.

    Regards
    Latheesh

  11. Rumen
    Admin
    Rumen avatar
    14320 posts

    Posted 29 Apr Link to this post

    Hi Latheesh,

    Thank you for the details!

    In this case, you can cache the first 100k items on the server as shown in this demo https://demos.telerik.com/aspnet-ajax/treelist/examples/databinding/loadondemand/defaultcs.aspx, e.g.

     

            public DataTable TreeListSource
            {
                get
                {
                    if (Session["TreeListSource"] == null)
                    {
                        Session["TreeListSource"] = GetDataTable("SELECT TOP(10000) * FROM TestItems");
                    }
     
                    return Session["TreeListSource"] as DataTable;
                }
            }

     

    and configure RadGrid as usual with a normal amount of initially cached items.

     

    Best Regards,
    Rumen
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top