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

4 posts, 0 answers
  1. Jun
    Jun avatar
    30 posts
    Member since:
    May 2013

    Posted 11 Dec 2013 Link to this post

    I read this Page.
    ( http://stackoverflow.com/questions/1151987/can-i-set-an-unlimited-length-for-maxjsonlength-in-web-config
     http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/autocomplete/overview)

    My Test Source: 
    vs2012 , AdventureWorks2012Db, Person Table, Ef5,  KendoUIMvcApplication.
     
    @(Html.Kendo().AutoComplete()
       .Name("test") //The name of the autocomplete is mandatory. It specifies the "id" attribute of the widget.
       .DataTextField("FirstName") //Specifies which property of the Product to be used by the autocomplete.))
       .BindTo(Model)   //Pass the list of Products to the autocomplete.
       .Filter("contains") //Define the type of the filter, which autocomplete will use.
     )



  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 12 Dec 2013 Link to this post

    Hi,

    You can try the code from here.

    Regards,
    Atanas Korchev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. John
    John avatar
    1 posts
    Member since:
    Dec 2015

    Posted 28 Dec 2015 in reply to Atanas Korchev Link to this post

    Hi Atanas,

    You mentioned 3 solutions:

    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 first one, for I am using a chart, which is not pageable, I think?

    The second one, do you mean pass as lease properties of the model as possible, to reduce the data to process? I will do this.

     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;}

    But I must return a view result to the view page, not a json format one. I tried the solution, the asp.net mvc view only display the data in json, not page.

     

    Is there a solution for the root cause, not a workground?

     

    Thank you.

     

     

  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 04 Jan Link to this post

    Hello John,

    The original question is related to the AutoComplete widget and the error you are using is related to the default maxvalue defined by the ASP.NET MVC framework. That being said, the solution provided by my colleague should be sufficient.

    As to the additional comments, the Chart widgets has a navigator option that will allow you to reduce the visualized data: or you can pan/zoom the chart or selection:
    In general, you can pass additional values to the View, filter the source and still return a View result. This is not related to Kendo UI / UI for ASP.NET MVC widget by any means, but rather is general ASP.NET MVC knowledge. I would suggest you accomplish your goal without the Kendo UI widgets and once this is done, to include them. I am sure that they will work as expected when JavaScriptSerializer works properly.

    Regards,
    Georgi Krustev
    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
Back to Top
UI for ASP.NET MVC is VS 2017 Ready