title: Upload and Process CSV File in ASP.NET MVC 4 Architectural Considerations
body: <p>I am working on an ASP.NET MVC 4 Application that imports and processes a CSV file.  I am using a standard form and controller for the upload.  Here is an overview of what I am doing currently:</p>
  
  <p><strong>Controller Logic</strong></p>
  
  <pre><code>public ActionResult ImportRecords(HttpPostedFileBase importFile){
  
      var fp = Path.Combine(HttpContext.Server.MapPath("~/ImportUploads"), Path.GetFileName(uploadFile.FileName));
      uploadFile.SaveAs(fp);
  
      var fileIn = new FileInfo(fp);
      var reader = fileIn.OpenText();
       var tfp = new TextFieldParser(reader) {TextFieldType = FieldType.Delimited, Delimiters = new[] {","}};
      while(!tfp.EndOfData){
          //Parse records into domain object and save to database
      }
      ...
  }
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>@using (Html.BeginForm("ImportRecords", "Import", FormMethod.Post, new { @id = "upldFrm", @enctype = "multipart/form-data" }))
  {
      &lt;input id="uploadFile" name="uploadFile" type="file" /&gt;
      &lt;input id="subButton" type="submit" value="UploadFile" title="Upload File" /&gt;
  }
  </code></pre>
  
  <p>The import file can contain a large number of records (average 40K+) and can take quite some time to complete.  I'd rather not have a user sitting at the import screen for 5+ minutes for each file processed. I have considered adding a console application to watch the uploads folder for new files, and process when something new is added, but would like to see what input I receive from the community before starting my journey down this path.   </p>
  
  <p>Is there a more efficient way to handle this operation?  </p>
  
  <p>Is there a way to perform this action, allowing the user to continue about his/her merry way, and then notify the user when processing is done?</p>