title: How do you ensure a webpage waits for an upload to complete?
body: <p>I have the following code which is used to upload large files (~6MB) to an ASP .NET MVC2 application. After the file is uploaded it can take 5 minutes to return a response from the controller.</p>
  
  <p>During this time, IE9 does not show any sign that processing is not yet completed, i.e. user can select other file and re-post.</p>
  
  <p>How do you inform the user that an operation is not completed and disable the submit button until the old file processing is completed?</p>
  
  <pre><code>&lt;% using (Html.BeginForm("InvoiceImport", "Grid", 
                 FormMethod.Post, new { enctype = "multipart/form-data" }))
  {%&gt;
  &lt;input name="uploadFile" type="file" /&gt;
  &lt;input type="submit" name='invoice' value='Read'/&gt;
  &lt;%} %&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>[AcceptVerbs(HttpVerbs.Post)]
  [Authorize]
  ActionResult ImportFromFile(HttpPostedFileBase uploadFile)
  {
      Server.ScriptTimeout = 30 * 60;
      var res = ImportFromFile(uploadFile.InputStream); // takes lot of time
      TempData["Message"] = uploadFile.FileName + " Readed records " + res;
      return RedirectToAction("Complete");
  }
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>I looks like the most important issue is to prevent duplicate submits.
  I tried code below to prevent duplicate submits but for unknown reason Session["Upload"] is null 
  if submit button is pressed in second time. 
  How to prevent duplicate submits ?</p>
  
  <pre><code>View added
  
   &lt;% if (TempData["Message"]!=null) { %&gt;
     setTimeout( function() {
       showMessage ( '&lt;%= TempData["Message"] as string %&gt;');
      }, 300 );
      &lt;% } %&gt;
  
  
  Controller
  
  ActionResult ImportFromFile(HttpPostedFileBase uploadFile)
      {
  
          if (Session["Upload"] != null)
          {
              // todo: why this point is never reached ?
              TempData["Message"] = Session["Upload"] + " Please wait file is being processed";
              return View();
          }
  
          Session.Add("Upload", uploadFile.FileName);
          Server.ScriptTimeout = 30 * 60;
          ImportFromFile(uploadFile.InputStream);
          TempData["Message"] = uploadFile.FileName + " completed";
          Session.Remove("Upload");
          return RedirectToAction("Complete");
      }
  </code></pre>