我有以下代码,允许用户下载文件。我需要知道(如果可能的话)他们是否成功下载了文件。是否有任何类型的回调可以让我知道他们是否成功下载了它?
string filename = Path.GetFileName(url);
context.Response.Buffer = true;
context.Response.Charset = "";
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
context.Response.ContentType = "application/x-rar-compressed";
context.Response.AddHeader("content-disposition", "attachment;filename=" + filename);
context.Response.TransmitFile(context.Server.MapPath(url));
context.Response.Flush();
最佳答案
为什么不再添加一行让您知道它已经完成了?在 context.Response.Flush() 之后,应该完成。
关于c# - 如何判断文件是否已下载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1526947/