Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are using MVC <strong>4</strong>, be sure to check out <em><a href="https://stackoverflow.com/a/12278956/160173">this answer</a></em> as well.</p> <hr> <p>If you are still receiving the error:</p> <ul> <li>after setting the <code>maxJsonLength</code> property to its maximum value in web.config</li> <li>and you know that your data's length is less than this value</li> <li>and you are not utilizing a web service method for the JavaScript serialization</li> </ul> <p>your problem is is likely that:</p> <blockquote> <p>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. <em>(<a href="http://msdn.microsoft.com/en-us/library/system.web.configuration.scriptingjsonserializationsection.maxjsonlength.aspx" rel="noreferrer">MSDN: ScriptingJsonSerializationSection.MaxJsonLength Property</a>)</em></p> </blockquote> <p>Basically, the "internal" <code>JavaScriptSerializer</code> respects the value of <code>maxJsonLength</code> when called from a web method; direct use of a <code>JavaScriptSerializer</code> (or use via an MVC action-method/Controller) does <strong>not</strong> respect the <code>maxJsonLength</code> property, at least not from the <code>systemWebExtensions.scripting.webServices.jsonSerialization</code> section of web.config.</p> <p>As a workaround, you can do the following within your Controller (or anywhere really):</p> <pre><code>var serializer = new JavaScriptSerializer(); // For simplicity just use Int32's max value. // You could always read the value from the config section mentioned above. serializer.MaxJsonLength = Int32.MaxValue; var resultData = new { Value = "foo", Text = "var" }; var result = new ContentResult{ Content = serializer.Serialize(resultData), ContentType = "application/json" }; return result; </code></pre> <hr> <p><em>This answer is my interpretation of <a href="http://forums.asp.net/p/1356198/2782837.aspx#4024065" rel="noreferrer">this asp.net forum answer</a>.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload