How to force Chromium download dialog without file being ready

62 Views Asked by At

I want to send text file to user while the data is being processed. The user is being notified that the file will start downloading within few minutes but as we know user knows better and after about half a minute they refresh and try again.

Chromium browsers will not show download dialog until the file is ready (big data export) which can take up to 3 minutes. Meanwhile Firefox notifies the user straight away.

Is there a way to trick Chromium browsers into showing download dialog sooner?

EDIT: I do not have control over frontend (3rd party company)

Example code:

public async Task<IActionResult> Download()
{
  Response.Headers.Add("Content-Disposition", "attachment; filename=test.txt");
  Response.ContentType = "text/plain";
  await Response.StartAsync();

  await Response.WriteAsync("Hello World!");//Firefox shows that a file is downloading after this line
  //await Response.Body.FlushAsync();

  await Task.Delay(10000); //10s long operation

  return new EmptyResult();//Chromium browsers show the download dialog somewhere after this line
}
0

There are 0 best solutions below