title: How to increase the json size limit for ASP.NET WebAPI Post call?
body: <p>My form on the page is a little too large. It collects the monthly measurement data. Please take a look at the sample:</p>
  
  <pre><code>{
  "Year":2013,
  "Month":3,
  "Records":[
      {"Id":0,"Date":"3/1/2013","RiverSection":5,"UserNumber":56},
      {"Id":0,"Date":"3/1/2013","RiverSection":7,"UserNumber":200},
      {"Id":0,"Date":"3/1/2013","RiverSection":8,"UserNumber":556},
      {"Id":0,"Date":"3/2/2013","RiverSection":5,"UserNumber":56},
      {"Id":0,"Date":"3/2/2013","RiverSection":7,"UserNumber":200},
      ...
      ...
      {"Id":0,"Date":"3/31/2013","RiverSection":7,"UserNumber":200}
  }
  </code></pre>
  
  <p>So I am posting the big data to an APIController.</p>
  
  <p>I works fine in my local machine using the Visual Studio debugger server. But after I uploaded the code to the server (IIS 6). It gives a <code>500 Internal Server Error</code>.</p>
  
  <p>I tried posting some sample data and checked the length of the stringified json.</p>
  
  <p>In one sample data set, the length of my json is 5743, and I got a "success". But if the json size goes up to 17345, I got a <code>500 Internal Server Error</code>.</p>
  
  <p>So I tried to increase the limit of json. Base on <a href="https://stackoverflow.com/questions/1151987/can-i-set-an-unlimited-length-for-maxjsonlength-in-web-config/12278956#12278956">this post</a></p>
  
  <p>In <code>Web.Config</code>:</p>
  
  <pre><code>&lt;system.web.extensions&gt;
  &lt;scripting&gt;
    &lt;webServices&gt;
      &lt;jsonSerialization maxJsonLength="5000000"&gt;
      &lt;/jsonSerialization&gt;
    &lt;/webServices&gt;
  &lt;/scripting&gt;
  &lt;/system.web.extensions&gt;
  </code></pre>
  
  <p>But it is not working. </p>
  
  <p>There is another answer, using:</p>
  
  <pre><code>var serializer = new JavaScriptSerializer();
  serializer.MaxJsonLength = Int32.MaxValue;
  </code></pre>
  
  <p>But where should we place this code? in <code>Global.asax</code>?</p>
  
  <p>Please note I am using an IIS 6. So is it a problem? How can I correctly increase the limit of json size so that my data can hit the WebApi action?</p>
  
  <p>Thank you for any assistance.
    </p>