BlogEngine.Net JSON 序列化长度错误

本文关键字:错误 序列化 Net JSON BlogEngine | 更新日期: 2023-09-27 18:36:31

进入管理员帖子页面时收到以下错误:

"Message":
"Error during serialization or deserialization using the JSON JavaScriptSerializer.
The length of the string exceeds the value set on the maxJsonLength property.",
"StackTrace":"   
at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, SerializationFormat serializationFormat)
at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)
at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)", "ExceptionType":"System.InvalidOperationException"

如何在 BlogEngine.Net 中增加 JSON 长度?

BlogEngine.Net JSON 序列化长度错误

尝试通过以下方式更改配置文件

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

最好的方法是将 int32.maxvalue 赋值到 maxJSonLength 作为2147483647