Suppose I have a controller action method that returns FileResult
. Is it possible to detect whether file was actually downloaded completely to the client?
public ActionResult GetFile(int id)
{
DownloadInfo data = provider.GetInfo(id);
this.provider.MarkDownloadStart(id);
return File(Server.MapPath(data.Filename), "application/pdf");
}
I do store information when action is being invoked, but that only means that someone initiated download. It doesn't give me any information on the server whether download completed...
I also set content disposition header so file is supposedly never opened directly in browser but rather browser asks to open/save it. This makes it easier for the client to save the file...
My thinking
I suppose it's not possible to directly detect that download has actually taken place. but is it possible to do it some other way as by somehow:
- loading a view that
- has an
iframe
that - requests a file and
- the main view supervises download on the client because it has access to
iframe
so it sees whether file has finished downloading or not.
Even though upper scenario may seem feasible, I don't know how to actually do this supervision. Maybe there's some other - better - way of doing this task.
The main question being
Is it possible to detect on the server that the client finished file downloading completely and not cancelling it in between download?