title: JavaScriptSerializer maxJsonLength exeeded
body: <p>I am creating a web service in c# in visual studio 2013.
  I am connected to a database and using the following code for returning json.</p>
  
  <pre><code>[WebMethod]
  [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
  public string GetCustomer()
  {
      var json = "";
      var customer = from result in dc.Auto_Kada_SIA_Customers
                     select result;
  
      JavaScriptSerializer jss = new JavaScriptSerializer();
      jss.MaxJsonLength = Int32.MaxValue;
      json = jss.Serialize(customer);
      int t = json.Length;
      return json;
  }
  </code></pre>
  
  <p>but when i try to use it i get the following error</p>
  
  <pre><code>{
    "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)\r\n   at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, SerializationFormat serializationFormat)\r\n   at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj)\r\n   at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n   at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)",
    "ExceptionType": "System.InvalidOperationException"
  }
  </code></pre>
  
  <p>I would be ok if that is the case but the MaxJsonLentgh is set to 2,147,483,647 and the json.Length is 21,460,284.</p>
  
  <p>What is the problem and how can i fix it?</p>