简体   繁体   English

字符串的长度超过maxJsonLength属性上设置的值

[英]length of the string exceeds the value set on the maxJsonLength property

I have a .Net Web service (.asmx) which will return a Json string to my client. 我有一个.Net Web服务(.asmx),它将一个Json字符串返回给我的客户端。 However, some of my data is really large and I get this error occasionally. 但是,我的一些数据非常大,偶尔会出现此错误。

The length of the string exceeds the value set on the maxJsonLength property. 字符串的长度超过maxJsonLength属性上设置的值。

I've changed the maxJsonLength property to 2147483644, but it still doesn't work. 我已将maxJsonLength属性更改为2147483644,但它仍然无效。 Please help... Thank you. 请帮忙......谢谢。

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



[WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public void GetData(string login)
        {
            // throw an error on this line...
            string result = new JavaScriptSerializer().Serialize(service.GetData(login));


            Context.Response.Write(result);
        }

Thanks to Ed Gibbs and @NextInLine 's suggestion. 感谢Ed Gibbs和@NextInLine的建议。 I did the fix as below and it work like a charm now. 我做了如下修复,它现在就像一个魅力。 I also removed the "system.web.extensions" portion away from my web.config 我还从web.config中删除了“system.web.extensions”部分

[WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public void GetData(string login)
        {

            // when the amount of data return is huge
            var serializer = new JavaScriptSerializer();

            // we need to do this.
            serializer.MaxJsonLength = Int32.MaxValue;


            var result = serializer.Serialize(service.GetData(login));


            Context.Response.Write(result);
        }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 字符串的长度超过maxJsonLength属性c上设置的值。 - The length of the string exceeds the value set on the maxJsonLength property.c# 字符串的长度超过了 mvc 中 maxjsonlength 属性上设置的值 - the length of the string exceeds the value set on the maxjsonlength property in mvc MVC4错误:字符串的长度超过了在maxJsonLength属性上设置的值 - MVC4 error: The length of the string exceeds the value set on the maxJsonLength property 正在检测字符串的长度超过在服务器上的maxJsonLength属性上设置的值 - Detecting The length of the string exceeds the value set on the maxJsonLength property at the server 我收到“字符串的长度超过 maxJsonLength 属性上设置的值” - I am getting a “The length of the string exceeds the value set on the maxJsonLength property” 错误“字符串的长度超过了 maxJsonLength 属性上设置的值。” - Error 'The length of the string exceeds the value set on the maxJsonLength property.' 尝试将部分视图转换为字符串时,“字符串的长度超出了在maxJsonLength属性上设置的值。” - “The length of the string exceeds the value set on the maxJsonLength property.” when trying to convert a partial view to string ASP.Net WebForm c#Web服务-字符串的长度超过在maxJsonLength属性上设置的值 - ASP.Net WebForm c# WebService - The length of the string exceeds the value set on the maxJsonLength property 使用JSON JavaScriptSerializer时发生错误“字符串的长度超过了在maxJsonLength属性上设置的值” - Error when using JSON JavaScriptSerializer “The length of the string exceeds the value set on the maxJsonLength property” 字符串超过maxJsonLength且小于250kb - String exceeds maxJsonLength with less than 250kb
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM