Reputation: 4786
I have a simple web app which allows downloading files.
The file gets downloaded correctly, however the browser never indicates the amount of data received (i.e. the progress).
It just keeps showing 0.1 MB until suddenly the file is downloaded.
Download action is implemented as follows - for now, simply open-read the local file and return the stream as File result.
public async Task<IActionResult> Download(string id)
{
var project = await this.service.GetById(id).ConfigureAwait(false);
if (project == null)
{
return this.NotFound($"Project [{id}] does not exist");
}
var file = new FileInfo(project.DownloadLocation);
this.Response.ContentLength = file.Length;
return this.File(file.OpenRead(), "application/octet-stream", file.Name);
}
The download is triggered by a simple action link:
<dd class="project-path">@Html.ActionLink("Here", "Download", "Download", new { id = Model.Id})</dd>
Any idea why Chrome/Firefox never shows the download progress?
Upvotes: 1
Views: 1792
Reputation: 10790
Your code should do the trick. You should try it with a larger file (eg:200mb)? It might be the reason time to calculate ETA taking more than downloading it in a local development environment.
Upvotes: 1