"There was an error serializing or deserializing using JSON javascriptserializer. The length of the string exceeds the value set for the Maxjsonlength property "
Business today look for me. The country area on the line shows the number (region ID) instead of the region name.
At that time, I think it is not possible ah, although the control is very old, has been replaced, not to the release date, but the code on the line absolutely no problem ah.
When I go to see the page, just crazy, there is really a problem, but the code on the online master is attached locally to the process is fully OK.
Guess:
1, the online JS file has changed;
2, the configuration file has changed
And then start looking at the Git record discovery today without uploading a record. Look at the online log and find a strange exception: the bold line above.
And then I started to think it was a code problem.
Asked the next Niang, see most of the solutions to this problem:
In the Web. config node, add the following:
<system.web.extensions> <scripting> <webServices> <jsonserialization Maxjsonlength="1024000000" /> </webServices> </scripting>< /system.web.extensions>
This is used to increase the length value of the maxjsonlength .
Combined with their own projects, the original old control, not the page loading area but take the full amount (the previous development dug pit), usually always use MVC json () to serialize the data into JSON format, yesterday suddenly increased the information of several cities, the amount of data increased to more than 49,000, take the entire data is, the bursting
Maxjsonlength Default value (online is said to be 4M, there is said 2M). Sad reminder of the small, with will not have the QA of the page loaded control also uploaded, fortunately there is no problem.
Problem solved, but the small part still feel that there are doubts, on the query more posts, found a more perfect way:
Public ActionResult Getlargejsonresult () { returnnew contentresult { New JavaScriptSerializer {maxjsonlength = Int32.MaxValue}. Serialize (Listresult), "application/json" };}
In addition, found a more thorough explanation of the post, attached address: http://www.cnblogs.com/artech/archive/2012/08/15/action-result-03.html
. NET using JSON (), Maxjsonlength property Set value problem