none
The length of the string exceeds the value set on the maxJsonLength property in SharePoint 2013 list form

    질문

  • I am getting an error when I open a SharePoint list display/New form.The list have couple of lookup columns. The size of lookup lists is big (around 20K items)

    A Variable called WPQ2FormCtx load all lookup lists titles with ID in page view source.

    The var WPQ2FormCtx exceed the maxJsonLength property. 

    I tried to change the property in web.config, which does not resolve the issue. Is there anyway to stop loading var WPQ2FormCtx  in SharePoint list forms?

    ULS Error:

    System.InvalidOperationException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.   
     at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat)    
     at Microsoft.SharePoint.WebControls.ClientFormManager.OnPreRender(EventArgs e)    
     at System.Web.UI.Control.PreRenderRecursiveInternal()    
     at System.Web.UI.Control.PreRenderRecursiveInternal()    
     at System.Web.UI.Control.PreRenderRecursiveInternal()    
     at System.Web.UI.Control.PreRenderRecursiveInternal()    
     at System.Web.UI.Control.PreRenderRecursiveInternal()    
     at System.Web.UI.Control.PreRenderRecursiveInternal()    
     at System.Web.UI.Control.PreRenderRecursiveInternal()    
     at System.Web.UI.Control.PreRenderRecursiveInternal()    
     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    2014년 7월 8일 화요일 오전 9:38

모든 응답

  • http://stackoverflow.com/questions/1151987/can-i-set-an-unlimited-length-for-maxjsonlength-in-web-config

    The MaxJsonLength property cannot be unlimited, is an integer property that defaults to 102400 (100k).

    You can set the MaxJsonLength property on your web.config:

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

    http://social.msdn.microsoft.com/Forums/en-US/255bb9a4-ad57-4f4e-8d4a-f684cd1ecf18/maxjsonlength-attribute-in-webconfig-is-ignored

     the behavior your are describing is "just the way it is."  Reviewing this docs page:

    http://msdn.microsoft.com/en-us/library/system.web.configuration.scriptingjsonserializationsection.maxjsonlength.aspx

     

    I see in the remarks section that "The value of the MaxJsonLength property applies only to the internal JavaScriptSerializer instance that is used by the asynchronous communication layer to invoke Web services methods."

    If I'm reading that correctly, that means that only web methods (not MVC action methods) will observe the value set by the maxJsonLength property.  If that's the case, I suspect this is an oversight on behalf of the ASP.NET MVC team--I can't imagine why wouldn't want the Controller.Json(objectToSerialize) method to also use the maxJsonLength method.

    As a workaround, you can do the following:

                JavaScriptSerializer serializer = new JavaScriptSerializer();

                serializer.MaxJsonLength = Int32.MaxValue; // Whatever max length you want here

                var resultData = new { Value = "3", Text = "MD" }; // Whatever value you are serializing

                ContentResult result = new ContentResult();

                result.Content = serializer.Serialize(resultData);

                result.ContentType = "application/json";

                return r;

     

    Then you have the option of creating your own helper methods and/or result types to wrap that up into a convenient package.  For instance, you could create a "LargeJsonResult" class that inherits from ContentResult, and takes the result object as a constructor parameter.  Then, in your action methods, you can simply do: "return LargeJsonResult(objectToSerializeToJson);"


    If this helped you resolve your issue, please mark it Answered

    2014년 7월 8일 화요일 오전 9:46
    중재자
  • This is an Out of the Box SharePoint Json output and we have no control over it. I have tried to change the I MaxJasonProperty in web config which does not resolve it. 
    2014년 7월 8일 화요일 오전 10:00
  • Hi Rashid - Will you be able to share your blog elsewhere ? link on workaround does not seem to work anymore.
    • 편집됨 Banu Pavithra 2017년 9월 6일 수요일 오전 8:48
    2017년 9월 6일 수요일 오전 8:47
  • The above URL(http://www.eblogin.com/eblogin/post/2014/07/18/WPQ2FormCtx-_maxJsonLengthproperty_SP2013.aspx) is not working.
    2017년 10월 26일 목요일 오전 6:01
  • From Web Archive:

    https://web.archive.org/web/20140802020840/http://www.eblogin.com:80/eblogin/post/2014/07/18/WPQ2FormCtx-_maxJsonLengthproperty_SP2013.aspx

    2018년 7월 13일 금요일 오후 2:30