title: Maximum http request size for asp web.api with json
body: <p>I have web api project.</p>
  
  <p>I need to post there json data with file as encoded base64 string (up to 200 mb).</p>
  
  <p>If i send data up to about 10 mb, then next method normally get properly filled model ImportMultipleFileModel.</p>
  
  <pre><code>[HttpPost]
      public async Task&lt;HttpResponseMessage&gt; ImportMultipleFiles(ImportMultipleFileModel importMultipleFileModel)
      { 
          var response = ImportFiles(importFileModel);
          return response;
      }
  </code></pre>
  
  <p>If i send more, then model is null. </p>
  
  <p>Why?</p>
  
  <p>So i change method signature to:</p>
  
  <pre><code>    [HttpPost]
          public async Task&lt;HttpResponseMessage&gt; ImportMultipleFiles()
          {
              ImportMultipleFileModel importMultipleFileModel = null;
              var requestData = await Request.Content.ReadAsStringAsync();
              try
              {
                  JsonConvert.
                  importMultipleFileModel = JsonConvert.DeserializeObject&lt;ImportMultipleFileModel&gt;(requestData);
              }catch(Exception e)
              { }
  }
  </code></pre>
  
  <p>And for encoded 30 mb file i normally get requestData as json string. For 60 mb i get empty string. 
  Why?</p>
  
  <p>Next i change method to </p>
  
  <pre><code>    [HttpPost]
          public async Task&lt;HttpResponseMessage&gt; ImportMultipleFiles()
          {
              ImportMultipleFileModel importMultipleFileModel = null;
              var requestData = Request.Content.ReadAsStringAsync().Result;
              try
              {
                  importMultipleFileModel = JsonConvert.DeserializeObject&lt;ImportMultipleFileModel&gt;(requestData);
              }catch(Exception e)
              { }
  }
  </code></pre>
  
  <p>And deserialization failed because of OutOfMemoryException.</p>
  
  <p>Why?</p>
  
  <p>UPD:
  maxRequestLength, maxAllowedContentLength set to 2147483647 </p>