title: ASP.Net WEB API Failing POST Large JSON data from Mobile
body: <p>I am using ASP.net WEB api from Mobile.Its failing every time.I am getting this error.</p>
  
  <pre><code>Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
  </code></pre>
  
  <p>I already added maxJsonLength on Webconfig</p>
  
  <pre><code>    &lt;system.webServer&gt;
      &lt;modules&gt;
        &lt;remove name="FormsAuthentication" /&gt;
        &lt;remove name="ApplicationInsightsWebTracking" /&gt;
        &lt;add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" /&gt;
      &lt;/modules&gt;
      &lt;validation validateIntegratedModeConfiguration="false" /&gt;
      &lt;security&gt;
        &lt;requestFiltering&gt;
          &lt;requestLimits maxAllowedContentLength="2147483648" /&gt;
        &lt;/requestFiltering&gt;
      &lt;/security&gt;
    &lt;/system.webServer&gt;
    &lt;system.web.extensions&gt;
      &lt;scripting&gt;
        &lt;webServices&gt;
          &lt;jsonSerialization maxJsonLength="2147483644"/&gt;
        &lt;/webServices&gt;
      &lt;/scripting&gt;
    &lt;/system.web.extensions&gt;
  </code></pre>
  
  <p>This is My controller how can i get then JSON inside postDataForSync Method ?
   for now its crashing after constructor method.</p>
  
  <pre><code> public class MobileAPIController : Controller
  {
      JavaScriptSerializer serializer;
      public MobileAPIController() {
  
          serializer = new JavaScriptSerializer();
          serializer.MaxJsonLength = Int32.MaxValue;
  
      }
  
  
      //
      //GET : MobileAPI/login
  
      public object login(string userId, string password)
      { 
      }
  
      //
      //GET : MobileAPI/getDataForSync
      public object getDataForSync(string userId) {
  
      }
  
      //
      //POST : MobileAPI/postDataForSync
      [HttpPost]
      public object postDataForSync(string syncData_)
      {
      }
  }
  </code></pre>
  
  <p>Error ,</p>
  
  <pre><code>[ArgumentException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
  Parameter name: input]
     System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) +168
     System.Web.Mvc.JsonValueProviderFactory.GetDeserializedObject(ControllerContext controllerContext) +211
     System.Web.Mvc.JsonValueProviderFactory.GetValueProvider(ControllerContext controllerContext) +16
     System.Web.Mvc.ValueProviderFactoryCollection.GetValueProvider(ControllerContext controllerContext) +69
     System.Web.Mvc.ControllerBase.get_ValueProvider() +30
     System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +62
     System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +105
     System.Web.Mvc.Async.&amp;lt;&amp;gt;c__DisplayClass21.&amp;lt;BeginInvokeAction&amp;gt;b__19(AsyncCallback asyncCallback, Object asyncState) +743
     System.Web.Mvc.Async.WrappedAsyncResult`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +14
     System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
     System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +343
     System.Web.Mvc.Controller.&amp;lt;BeginExecuteCore&amp;gt;b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +25
     System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
     System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
     System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +465
     System.Web.Mvc.Controller.&amp;lt;BeginExecute&amp;gt;b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller) +18
     System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +20
     System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
     System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +374
     System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +16
     System.Web.Mvc.MvcHandler.&amp;lt;BeginProcessRequest&amp;gt;b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +52
     System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
     System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
     System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +384
     System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48
     System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
     System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +103
     System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +48
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp;amp; completedSynchronously) +159
  &lt;/pre&gt;
                          &lt;/code&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
              &lt;br&gt;
              &lt;hr width=100% size=1 color=silver&gt;
              &lt;b&gt;Version Information:&lt;/b&gt;&amp;nbsp;Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3062.0
  </code></pre>
  
  <p>Thank you.</p>