We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Error serialization in Grid Control using JSON

Thread ID:

Created:

Updated:

Platform:

Replies:

124030 May 10,2016 11:00 AM May 11,2016 05:14 AM ASP.NET MVC 2
loading
Tags: Grid
André Secco
Asked On May 10, 2016 11:00 AM

Hello,

I'm in trouble with the serialization of my data in my Grid Control, I get the following message: "Error during serialization or deserialization using JSON JavaScriptSerializer. The size of the string exceeds the value set in maxJsonLength property".

I've seen some alternatives in forum, but nothing help me.
I do not want paging in my grid and I have to have all the data on the screen to be analyzed.
I have to render it without being in Json? Or you have another alternative?

André Secco
Replied On May 10, 2016 03:05 PM

I already try input the config in web.config (But not working):

<system.web.extensions>
  <scripting>
    <webServices>
      <jsonSerialization maxJsonLength="50000000"/>
    </webServices>
  </scripting>
</system.web.extensions>
I researched on the internet and saw that can happen because web.config setting will be ignored because you're using an internal instance of the JavaScriptSerializer.
In the forums it is recommended to do the following (Adding MaxJsonLength property):
protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior)
{
    return new JsonResult()
    {
        Data = data,
        ContentType = contentType,
        ContentEncoding = contentEncoding,
        JsonRequestBehavior = behavior,
        MaxJsonLength = Int32.MaxValue
    };
}
As the Grid component of Syncfusion is compiled, I have no way to access and make a override. Any idea how to solve (without paging)?

Jayaprakash Kamaraj [Syncfusion]
Replied On May 11, 2016 05:14 AM

Hi André, 
Thank you for contacting Syncfusion support. 

In our latest MVC grid, we have rendered all the html elements in client side and we have passed the data to the control from server side to client side as Json data by serializing it.  

And we have used the default MaxJsonLength value (2097152 characters, which is equivalent to 4 MB of Unicode string data) of the JavaScriptSerializer which is a fixed universal standard length for serializing the data.  

We have already discussed the same issue in following knowledge base document.   
Regards, 
Jayaprakash K. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;