InvalidOperationException despite MaxJsonLength = Int32.MaxValue

一世执手 提交于 2019-12-11 06:29:12

问题


I don't think I'm exceeding the MaxJsonLength, but I'm still getting "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property".

I checked to see how long the result is, and it's 25,000 rows. I checked the average length of each row by outputting a smaller result, and the average row is 48.5 characters long.

25,000 * 48.5 characters = 1,224,140 characters.

MS says that maxJsonLength is in terms of characters. Int32.MaxValue is over 2 billion. What gives?

Note: I'm not using MVC, and this is a WebMethod written in VB 2010 talking to jQuery. The results are organized using a dictionary array. I get results for smaller sets just fine. I confirmed that my serializer's maxJsonLength was set to max.

Many thanks in advance!


回答1:


In ASP.NET there is a default max value of 1000 JSON members for deserialization. It was introduced last December. See if this is the issue with your application. Here's an article for this.



来源:https://stackoverflow.com/questions/12749229/invalidoperationexception-despite-maxjsonlength-int32-maxvalue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!