Go ASP. NET MVC JSON () handles big Data exception resolution JSON Maxjsonlength

Source: Internet
Author: User

This article transferred from: http://blog.csdn.net/blacksource/article/details/18797055

Let's start with a brief introduction to the project:

The whole project was developed using Microsoft's ASP. NET MVC3, the front-end display uses the Easyui frame, the chart display uses the Highcharts, mainly carries on the plot of the graph, thus the comparison vividly depicts the change trend. Because the data volume is large (greater than 1000,000 Records), and the data type accepted by Highcharts is in JSON format, the data that the controller takes out of the database needs to be formatted as JSON before being uploaded to the front end. Always use MVC json () to serialize the data into JSON format, but because of this large amount of data, so the curve is not displayed, so always thought it is due to the large amount of data, highcharts plug-in does not support 100w data, Later heard that the highcharts itself is to support 100w-level data. Finally, using Firebug debugging, we found an error: "There was an error serializing or deserializing using JSON javascriptserializer." The length of the string exceeds the value set for the Maxjsonlength property "and many solutions have been found on the web, with almost no exception being added under the node for Web. config:

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

After trying to find the curve still did not come out, finally took out the killer: Google translated into English, re-search, finally found a solution to the StackOverflow on the law:

public ActionResult GetLargeJsonResult(){  return new ContentResult    {        Content = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }.Serialize(myBigdata),        ContentType = "application/json"    };}

Specific website: http://stackoverflow.com/questions/4155014/json-asp-net-mvc-maxjsonlength-exception

Here have to praise StackOverflow, a lot of problems are found in the above solution, and there are a lot of good-hearted people who are enthusiastic and meticulous to answer questions, I mentioned a number of issues have finally been so-called geek help and resolved. Here, I just want to say: Thank you.

Go ASP. NET MVC JSON () handles big Data exception resolution JSON Maxjsonlength

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.