Is There Any Event/way We Can Know When A File Has Finished Downloading?
This question has been asked a much time, but I am unable to get a perfect answer to implement. So I give it a try asking one more time. Suppose you wish to show a message when you
Solution 1:
When you request a file from your server, send a unique key to the download service from the client.
GET /Download?fileId=someId&cookieName=abc
When the server has finished serving the file contents, set a cookie with the unique name
var cookieName = Request.QueryString["cookieName"];
Response.Cookies.Add(new HttpCookie(cookieName , "true")
{
Path = "/",
HttpOnly = false
});
Meanwhile, in your JavaScript, listen for a cookie with your unique name on it and once it is set, do a callback:
window.setInterval(function () {
var cookie = $.cookie('abc');
if (cookie !== null) {
callback();
}
}, 500);
You might also want to look into deleting the cookie when you are done.
Post a Comment for "Is There Any Event/way We Can Know When A File Has Finished Downloading?"