title: ASP.net Still cannot upload files over 80KB
body: <p>I am trying to process line by line a file that can be a few hundred kilobytes in length, but when I try to upload a file that is over 80KB in length I get an exception:</p>
  
  <pre><code>Object Disposted Exception: Cannot access a closed file.
  </code></pre>
  
  <p>The file is uploaded to a controller and passed on to an Async task like so:</p>
  
  <pre><code>public JsonResult Index(HttpPostedFileBase csvFile)
  {
          AsyncManager.OutstandingOperations.Increment();
  
          System.Threading.Tasks.Task.Factory.StartNew(() =&gt; {
  
              ProcessFile(csvFile);
  
              AsyncManager.OutstandingOperations.Decrement();
          });
          return Json(new {fileId = fileId});
  }
  </code></pre>
  
  <p>This then processes the file</p>
  
  <pre><code>    public static void ProcessFile(HttpPostedFileBase csvFile) {
  
          Int32 lineCount = 0;
          StreamReader lineCounter = new StreamReader(csvFile.InputStream);
  
          while (lineCounter.ReadLine() != null) { // exception occurs here with lineCount still 0
              lineCount += 1;
          }
          //Continue processing
  </code></pre>
  
  <p>I understand that by default it will not accept files larger than 80KB, but I have added the following lines to my web.config:</p>
  
  <pre><code>  &lt;system.web&gt;
      &lt;httpRuntime executionTimeout="3600" maxRequestLength="30000000" requestLengthDiskThreshold="30000000" useFullyQualifiedRedirectUrl="false" /&gt;
    &lt;/system.web&gt;
  
      &lt;system.webServer&gt;
      &lt;security&gt;
        &lt;requestFiltering&gt;
          &lt;requestLimits maxAllowedContentLength="30000000" /&gt;
        &lt;/requestFiltering&gt;
      &lt;/security&gt;
    &lt;/system.webServer&gt;
  </code></pre>
  
  <p>But this does not change the outcome. It works fine with files all the way up to 79KB.</p>
  
  <p>Is there something else I need to add?</p>
  
  <h2>Update:</h2>
  
  <p>My solution was to save the file locally in App_Data, and pass in the file location instead of the actual file. As far as I can tell, there is still no reason why IIS did not accept files larger than 80KB, and fail as soon as I try to access it, while a 79KB file runs through fine. I have no third party libraries and no other process or code is trying to access the file</p>