Looked far and wide and still cannot find a way to synchronously download generated files from a form POST. I know the process is asynchronous but I want to keep the user waiting OR allow them to download other files while others are downloading.
My page asks the user for a file ID and then generates that file and sends the user the file requested. Either they wait or keep on downloading other files and get a "File save" dialog for each one as they come.
As soon as the user asked for a new file while the last request did not complete downloading, the process is canceled and only the new request is processed (downloaded).
I tried with Ajax (jQuery) but it is not working. I can wait on upload but not on download and plus there is a security issue showing the URL to the file and the file is never saved on the server to begin with.
Any help would be appreciated.
c# code
[HttpPost]
public ActionResult GetFile(int id)
{
//code
return File(fileData, contentType, originalFileName);
}