代码之家  ›  专栏  ›  技术社区  ›  Sameer

JSON maxJsonLength属性

  •  -1
  • Sameer  · 技术社区  · 8 年前

    我在中使用以下代码 。cshtml 文件

    var typeVM = JSON.parse('@Html.Raw(Json.Encode(Model.typeVM))');

    显示以下错误: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

    我无法定义最大长度 Json Encode 功能和 网状物配置 配置仅适用于 web服务

    所以问题是这个问题的可能解决方案是什么?
    如何定义 jsonMaxLength 所有物

    2 回复  |  直到 8 年前
        1
  •  1
  •   Shahzad Khan    8 年前

    我假设您从中获取数据的是一个web服务(因为您的问题被标记为“web服务”),请更改web中的maxlength。配置:

     <configuration> 
       <system.web.extensions>
           <scripting>
               <webServices>
                   <jsonSerialization maxJsonLength="50000000"/>
               </webServices>
           </scripting>
       </system.web.extensions>
    </configuration> 
    
        2
  •  0
  •   Md Nazrul Islam    8 年前
    Model variable must be short 
    for example 
    model.First_name it should be short to model.FN
    

    我希望这对你有用。。