title: asp.net core webapi frombody parameter size limit
body: <p>I have implemented an endpoint in ASP.NET Core 3.1 to retrieve a large JSON object, and I'm having an issue when this JSON starts to be relatively large. I start to have issues around 5~600KB.</p>
  <p>For requests that have a body lower than 600~500KB, everything works fine.</p>
  <p>The endpoint is defined like this:</p>
  <pre><code>[DisableRequestSizeLimit]
  [RequestFormLimits(ValueCountLimit = int.MaxValue)]
  [HttpPost]
  [Route(&quot;MyTestEndpoint&quot;)]
  public void PostTest([FromBody]object objVal)
  {
      // objVal is null when the post is larger than ~5~600KB
      string body = objVal.toString;
      ....
  }
  </code></pre>
  <p>web.config:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;configuration&gt;
    &lt;location path=&quot;.&quot; inheritInChildApplications=&quot;false&quot;&gt;
  &lt;system.web&gt;
      &lt;httpRuntime  maxRequestLength=&quot;1048576&quot; /&gt;  
  &lt;/system.web&gt;
  
      &lt;system.webServer&gt;
        &lt;handlers&gt;
          &lt;add name=&quot;aspNetCore&quot; path=&quot;*&quot; verb=&quot;*&quot; modules=&quot;AspNetCoreModuleV2&quot; resourceType=&quot;Unspecified&quot; /&gt;
        &lt;/handlers&gt;
        &lt;aspNetCore processPath=&quot;dotnet&quot; arguments=&quot;.\ApiSLPCalendar.dll&quot; stdoutLogEnabled=&quot;true&quot; stdoutLogFile=&quot;.\logs\stdout&quot; hostingModel=&quot;inprocess&quot; /&gt;
        &lt;security&gt;
          &lt;requestFiltering&gt;
            &lt;!-- This will handle requests up to 100MB --&gt;
            &lt;requestLimits maxAllowedContentLength=&quot;1048576000&quot; /&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=&quot;50000000&quot;/&gt;
             &lt;/webServices&gt;
         &lt;/scripting&gt;
  &lt;/system.web.extensions&gt;
  
    &lt;/location&gt;
  &lt;/configuration&gt;
  </code></pre>
  <p>Startup.cs:</p>
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
  
              services.AddControllers().ConfigureApiBehaviorOptions(options =&gt;
              {
                  options.SuppressConsumesConstraintForFormFileParameters = true;
                  options.SuppressInferBindingSourcesForParameters = true;
                  options.SuppressModelStateInvalidFilter = true;
                  options.SuppressMapClientErrors = true;
              });
              services.AddMvc(options =&gt;
              {
                  options.MaxModelBindingCollectionSize = int.MaxValue;
              });
  
              services.Configure&lt;FormOptions&gt;(x =&gt;
              {
                  x.ValueLengthLimit = int.MaxValue;
                  x.MultipartBodyLengthLimit = int.MaxValue;
              });
  ....
  }
  </code></pre>
  <p>Do you have any clue why this happens?</p>
  <p>******* EDIT *******</p>
  <p>I've tried several changes but none of them has worked fine.</p>
  <p>Finally, following the discussion on <a href="https://stackoverflow.com/questions/40853188/frombody-string-parameter-is-giving-null">FromBody string parameter is giving null</a> I've modified the method, defining a model, removing the generic object, as a parameter.
  The front-end has been modified to send a key=&quot;value&quot;, where &quot;Value&quot; represents a stringified JSON object.</p>