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.
Syncfusion Feedback

Grid Error during the serialization with JSON JavaScriptSerializerJavaScriptSerializer. The lenht is higger than maxJsonLength property

Thread ID:

Created:

Updated:

Platform:

Replies:

121156 Nov 15,2015 08:23 PM UTC Feb 16,2016 05:11 AM UTC ASP.NET Web Forms 15
loading
Tags: Grid
Manolo
Asked On November 15, 2015 08:23 PM UTC

Hi,

I need fill a grid with a 6k registers but I get this error.

I change the WebConfig but I get the same error.

I read about create a webservice, but I can't do it.

Attach an example that load data from a test server.



Attachment: WebApplication1_50a2089c.zip

Gowthami V [Syncfusion]
Replied On November 16, 2015 05:06 AM UTC

Hi Manolo,

Thanks for using Syncfusion products.

The issue “Error during serialization or deserialization with JavaScriptSerializer of JSON” can be resolved by using WebMethodAdaptor, which is used for performing server side operations.

Please refer the below KB link for more clarification about WebMethodAdaptor.

KB Link:
 http://www.syncfusion.com/kb/4300/server-side-api-for-datamanager-operations

Refer to the below code example,

Default.aspx

<ej:Grid ID="gridDataReport" runat="server" AllowPaging="true">

        <DataManager URL="Default.aspx/GetData" Adaptor="WebMethodAdaptor" />

        <Columns>           

            <ej:Column Field="FechaInforme" ></ej:Column>

            <ej:Column Field="IdTeam" ></ej:Column>

        </Columns>


    </ej:Grid>


Default.aspx.cs


using Syncfusion.Linq;


[WebMethod]

[ScriptMethod(ResponseFormat = ResponseFormat.Json)]


public static List<InformeDiarioGas> GetData(Syncfusion.JavaScript.DataManager value)

        {       

            var db = new Model1();


            IEnumerable result = db.InformeDiarioGas.ToList<InformeDiarioGas>();


            int count = result.AsQueryable().Count();

            Syncfusion.JavaScript.DataSources.DataOperations operation = new        Syncfusion.JavaScript.DataSources.DataOperations();

            result = operation.Execute(result, value);

            return new { result = result, count = count };
        }



Regards,

Gowthami V.



Manolo
Replied On November 16, 2015 07:59 AM UTC

Sorry,

I can not run my example with your modifications. The Page is always loading and no data is show.

Also, I pass filter parameters in the query string (in the example not) and I can't get this parameters in static funciton.



Gowthami V [Syncfusion]
Replied On November 17, 2015 10:22 AM UTC

Hi Manolo,
We have already faced the issue “addParams not working when using WebMethodAdaptor” and we have fixed the issue in the version “13.3.0.7”.


So we suggest you to upgrade your product to the latest version 13.3.0.12 version.

Please follow the below steps to upgrade to 13.2.0.34 to 13.3.0.12.

1.       Download and install the Essential Studio v13.3.0.12 from the below link.

   http://www.syncfusion.com/forums/121006/essential-studio-2015-volume-3-service-pack-1-release-v13-3-0-12-available-for-download

2.       Replace the Syncfusion dlls, scripts, and css in your project from the following location.

            Scripts and Css: C:\Program Files (x86)\Syncfusion\Essential Studio\XX.X.X.XX\JavaScript\assets

            Dlls: C:\Program Files (x86)\Syncfusion\Essential Studio\ XX.X.X.XX \Assemblies

Here XX.X.X.XX denotes the product version(13.3.0.12).

We have modified your sample (in version 13.3.0.12) and the same can be downloaded from the following link,

http://www.syncfusion.com/downloads/support/directtrac/general/WEBAPP~32140304254.ZIP

Refer to the below code example,

[WebMethod]

        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]


        public static object GetData(Syncfusion.JavaScript.DataManager value, int? EmployeeID)

        {

            var db = new Model1();


            IEnumerable result = db.InformeDiarioGas.ToList<InformeDiarioGas>();


            int count = result.AsQueryable().Count();

            Syncfusion.JavaScript.DataSources.DataOperations operation = new Syncfusion.JavaScript.DataSources.DataOperations();


            result = operation.Execute(result, value);

            return new { result = result, count = count };

        }

 

We can get the additional parameter as highlighted in the above code example.

If we misunderstood your requirement please share the stack trace of the issue and the provided information will help to analyze the issue and provide you the response as early as possible.

Regards,

Gowthami V.


Manolo
Replied On November 19, 2015 04:20 PM UTC

Ok, it works

But I like like know if is possible, in a future update, modify the MaxJsonLength, (or the neccesary parameter) for load large amount of data with datasource's assignation.

Using a WebMethod, for example, I can't export to excel with grid's datasource.

Thanks


Gowthami V [Syncfusion]
Replied On November 20, 2015 02:33 PM UTC

Hi Manolo,

Query 1: But I like like know if is possible, in a future update, modify the MaxJsonLength,

We tried to serialize the datasource by increasing the MaxJsonLength manually and it serialized the data successfully but it thrown “System.OutOfMemory Exception”.

So avoiding the unwanted exception kindly use our solution provided in previous response.

Query 2: Using a WebMethod, for example, I can't export to excel with grid's datasource.

We can achieve your requirement by pass the dataSource directly from the database instead of grid’s dataSource as follows,

protected void FlatGrid_ServerExcelExporting(object sender, Syncfusion.JavaScript.Web.GridEventArgs e)

        {

            var db = new Model1();

            ExcelExport exp = new ExcelExport();

            exp.Export(gridDataReport.Model, (IEnumerable)db.InformeDiarioGas.ToList<InformeDiarioGas>(), "Export.xlsx", ExcelVersion.Excel2010, true, true, "flat-lime");
        }


We have modified your sample with exporting and the same can be downloaded from the following link,

http://www.syncfusion.com/downloads/support/directtrac/general/ze/WebApplication1_50a2089c-1748256314.zip

Regards,

Gowthami V.

Manolo
Replied On February 2, 2016 12:34 PM UTC

I'm sorry for reopen this post, but I think that is better than create a new post.

For various reasons, I didn't need load large amount of data, but now, I need, so I revised this post.

Your example works fine, byt my problem is: I don't know how configure my project for use a webmethod. I try modified my example project (add webServices section in webconfig), but I don't get that my example works. So... What are the steps for use WebMethods in my project?

Thanks again



Gowthami V [Syncfusion]
Replied On February 3, 2016 09:58 AM UTC

Hi Manolo,


From your query we have understood that you want to bind the data to Grid Control from ASP.Net WebService which already discussed in the below KB document,


https://www.syncfusion.com/kb/5446/how-to-bind-webservice-to-grid-using-the-asp-net-webservice


If we misunderstood your requirement, please provide information about the issue, which will help to analyze and provide a solution as early as possible. 


Regards,


Gowthami V.





Manolo
Replied On February 5, 2016 07:45 AM UTC

I'm sorry, but I do not get to run webmethods.

I attach the example project, but GetData2 method is not executed.

I do not know what I forgot

Attachment: WebApplication1_4067a18f.zip

Madhu Sudhanan P [Syncfusion]
Replied On February 8, 2016 10:18 AM UTC

Hi Manolo,

We have analyzed the attached sample and we obtained the below authorization error when running your sample.



And hence to resolve the above problem, we suggest you to disable the auto-redirection mode in RouteConfig.cs file as below.



For more information on handling FriendlyUrls and authorization in ASP.Net application, please refer to the below links.

http://www.hanselman.com/blog/IntroducingASPNETFriendlyUrlsCleanerURLsEasierRoutingAndMobileViewsForASPNETWebForms.aspx

http://weblogs.asp.net/gurusarkar/setting-authorization-rules-for-a-particular-page-or-folder-in-web-config

http://stackoverflow.com/questions/32663858/#answer-32702382

Please let us know if you have any queries.

Regards,
Madhu Sudhanan P

Manolo
Replied On February 8, 2016 03:14 PM UTC

Ok!

Thank you very much!

Madhu Sudhanan P [Syncfusion]
Replied On February 9, 2016 03:56 AM UTC

Hi Manolo,

We are glad that the provided solution worked for you.

Regards,
Madhu Sudhanan P.

Manolo
Replied On February 11, 2016 07:32 PM UTC

Ups... I've other problem.

It works perfectly when I run in local server, but when I deploy the application in remote server, it's on a folder ( the server has other applications), so, the the property URL in datamanager doesn't works fine.

For example, if my application is deplsy in "web_test" folder, it doesn't work in remote but yes in local

<DataManager URL="Default.aspx/GetData" Adaptor="WebMethodAdaptor" />

and this works in remote, but not in local

<DataManager URL="/web_test/Default.aspx/GetData" Adaptor="WebMethodAdaptor" />

In URL, I can't set "." or "~" at start

If it is neccesary, i can upload the project into a test server




Gowthami V [Syncfusion]
Replied On February 12, 2016 05:50 PM UTC

Hi Manolo,

We have analyzed your issue and we are unable to reproduce the issue.

From your query we suspect that the issue is due to the path is not relative. For relative path we can use “ResolveUrl” property.

Refer to the below links for more clarification about ResolveUrl,

https://humrahimcs.wordpress.com/2011/05/06/use-of-resolveurl/

http://www.codeproject.com/Articles/142013/There-is-something-about-Paths-for-Asp-net-beginne

Regards,
2
Gowthami V.

Manolo
Replied On February 15, 2016 03:05 PM UTC

Sorry, I was an error

All is perfect! Thanks again!

Balaji Sekar [Syncfusion]
Replied On February 16, 2016 05:11 AM UTC

Hi Manolo, 

We are happy that the provided suggestion helped you.Please get back to us if you need any further assistance. 

Regards, 
Balaji S.

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.

Warning Icon 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.Close Icon

;