我的MVC3,C#,Web應用程序運行良好,直到一週前。沒有變化的數據或代碼,但是現在我們JSON序列化問題
接受「序列化和反序列化過程中的錯誤使用JSON JavaScriptSerializer。字符串的長度超過了價值上maxJsonLength屬性設置 。」
我試過做所有事情似乎,最後今天早上決定發送一個較小的一組數據(50條記錄),仍然沒有運氣。奇怪的是,該應用程序在測試上工作,但不在生產上。
頁面上接收到的錯誤是:
[InvalidOperationException: Error during serialization or deserialization using the JSON
JavaScriptSerializer. The length of the string exceeds the value set on the
maxJsonLength property.]
System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder
output, SerializationFormat serializationFormat) +588689
System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj,
SerializationFormat serializationFormat) +74
System.Web.Mvc.JsonResult.ExecuteResult(ControllerContext context) +231
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext
controllerContext, ActionResult actionResult) +13
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter,
ResultExecutingContext preContext, Func`1 continuation) +264
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext
controllerContext, IList`1 filters, ActionResult actionResult) +176
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext,
String actionName) +329
System.Web.Mvc.Controller.ExecuteCore() +115
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +94
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext
requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +31
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +23
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +59
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+9048061
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +184
MVC對測試的版本是2.0.41116.0,並在生產是2.0.41211.0。 我們目前發送的json爲List<List<string>>
,大小爲1,932,123。但是爲什麼它在測試上運行,而不是生產,這是令人困惑的。我看不出任何差異,但任何人都可以提出一些我可能錯過的檢查? 我已經嘗試更新配置文件(我知道這並不重要/工作),以及其他一些網上建議,但沒有骰子。
http://www.shabdar.org/asp-net/77-system-invalidoperationexception-maximum-length-exceeded.html的http:// dotnetbyexample .blogspot.com.tr/2007/11/expanded-lenght-of-json-data-returned.html http://dotnetarchitect.wordpress.com/2008/10/14/using-json-some-observations/ –
possible重複的[字符串的長度超過maxJsonLength屬性設置的值](http://stackoverflow.com/questions/11881198/the-length-of-the-string-exceeds-the-value-set-on- the-maxjsonlength-property) – mayabelle
錯誤來自JavaScriptSerialize r在System.Web.Extensions程序集中,因此你應該在你的測試環境和prod環境之間檢查一下,看看它是否一致。 –