title: The maximum size of object that can be passed as Parameter to POST method
body: <p>I have a web API controller with a POST method as follows.</p>
  
  <pre><code>public class MyController : ApiController
  {
      // POST: api/Scoring
      public HttpResponseMessage Post([FromBody]MyClass request)
      {
          // some processing of request object
          return Request.CreateResponse(HttpStatusCode.OK, someResponseObject);
      }
      ....
  }
  </code></pre>
  
  <p>This is consumed by a HTTPClient as follows</p>
  
  <pre><code>HttpClient httpClient = new HttpClient();
  httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  httpClient.BaseAddress = new Uri("http://localhost");
  MyClass requestClient = new MyClass();
  var task = httpClient.PostAsJsonAsync("api/my", requestClient)
  </code></pre>
  
  <p>It works great when MyObject object size passed in POST method parameter of controller is small in size. However in case when this object size is big, I get a null for the request object in the POST method parameters. In one case, the size of the requestClient object passed from client side request is ~5 MB and in the POST method, I get request object as null. <strong>Note that Web API is hosted under IIS.</strong> Is there any setting that I need to change for permissible size.</p>
  
  <p><strong>UPDATE:</strong> 
  Adding following in web.config solved the null object issue in the POST method parameter.</p>
  
  <blockquote>
    <p>httpRuntime  maxRequestLength="2147483647" /></p>
  </blockquote>
  
  <p>I then increased the size of <strong>requestClient</strong> object to ~50MB. Now the code in POST method never getting hit. On the client side, at the call to PostAsJsonAsyn, I get System.Net.HttpRequestException with following message.</p>
  
  <blockquote>
    <p>Response status code does not indicate success: 404 (Not Found).</p>
  </blockquote>
  
  <p>Now changing maxRequestLength doesn’t seem to have any impact.</p>