我在 .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.config 配置仅适用于网络服务。
所以问题是这个问题的可能解决方案是什么?
如何定义jsonMaxLength
属性?
答案 0 :(得分:0)
Model variable must be short
for example
model.First_name it should be short to model.FN
我希望它能帮到你..
答案 1 :(得分:0)
我认为这是一个Web服务,您从中获取数据(因为您的问题被标记为" web-service"),在web.config中更改maxlength:
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000"/>
</webServices>
</scripting>
</system.web.extensions>
</configuration>