我可以设置在web.config中为maxJsonLength无限的长度? [英] Can I set an unlimited length for maxJsonLength in web.config?

查看:1029
本文介绍了我可以设置在web.config中为maxJsonLength无限的长度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery的自动完成功能。当我尝试检索更多然后17000记录列表(每个不会有超过10个字符的长度),这是超过长度并引发错误:

I am using the autocomplete feature of jQuery. When I try to retrieve the list of more then 17000 records (each won't have more than 10 char length), it's exceeding the length and throws the error:

异常信息:

      异常类型:InvalidOperationException异常

      异常消息:使用JSON序列化的JavaScriptSerializer反序列化或过程中的错误。字符串的长度超过上maxJsonLength属性设置的值。

Exception information:
Exception type: InvalidOperationException
Exception message: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

我可以在的web.config 设置 maxJsonLength 无限长度是多少?如果不是,有什么我可以设置最大长度是多少?

Can I set an unlimited length for maxJsonLength in web.config? If not, what is the maximum length I can set?

推荐答案

注意:这个答案只适用于Web服务,如果你是从一个控制器方法返回JSON,请务必阅读本SO回答下面还有:<一href=\"http://stackoverflow.com/questions/1151987/can-i-set-an-unlimited-length-for-maxjsonlength-in-web-config/7207539#7207539\">http://stackoverflow.com/a/7207539/1246870

NOTE: this answer applies only to Web services, if you are returning JSON from a Controller method, make sure you read this SO answer below as well: http://stackoverflow.com/a/7207539/1246870

的<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.maxjsonlength.aspx\">MaxJsonLength财产不能是无限的,是一个整数属性,默认为102400(100K)。

The MaxJsonLength property cannot be unlimited, is an integer property that defaults to 102400 (100k).

您可以设置MaxJsonLength财产上你的web.config:

You can set the MaxJsonLength property on your web.config:

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

这篇关于我可以设置在web.config中为maxJsonLength无限的长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆