In my MVC 4 app, I have a view that uploads a file from the client machine with:
<snip>
@using (Html.BeginForm("Batch", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input class="full-width" type="file" name="BatchFile" id="BatchFile"
<input type="submit" value="Do It" />
}
<snip>
The "Batch" action in the home controller takes that file and processes it in a way that may be very lengthy.... minutes even:
<snip>
[HttpPost]
public FileResult Batch(ModelType modelInstance)
{
// Do the batch work.
string result = LengthyBatchProcess(modelInstance.BatchFile.InputStream)
var encoding = new ASCIIEncoding();
Byte[] byteArray = encoding.GetBytes(result);
Response.AddHeader("Content-Disposition", "attachment;filename=download.csv");
return File(byteArray, "application/csv");
}
<snip>
This all works fine, and it isn't an inherent problem that the user is locked out for the time it takes for the batch process to run. In fact they expect it. The problem is that the user may not be in a position to know whether this process will take a couple of seconds or a couple of minutes, and I would like to provide them with status information while LengthyBatchProcess is running. I have researched unobtrusive ajax, but it does not seem to have the functionality necessary for this, unless there is some way to chain unobtrusive ajax calls. Any thoughts on how to best architect this? Many thanks in advance.