C# 在启动下载文件请求时,让用户知道长操作
我有一些例行代码下载文件如下。然而,在处理这个过程中,下载文件的请求和即将出现的保存对话框之间有一段延迟时间,我想添加一些JavaScript模式警报,让用户知道挂起的操作。如何从用户控件轻松地执行此操作C# 在启动下载文件请求时,让用户知道长操作,c#,asp.net,C#,Asp.net,我有一些例行代码下载文件如下。然而,在处理这个过程中,下载文件的请求和即将出现的保存对话框之间有一段延迟时间,我想添加一些JavaScript模式警报,让用户知道挂起的操作。如何从用户控件轻松地执行此操作 System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.Clear(); response.ContentType =
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
response.ContentType = "text/plain";
response.AddHeader("Content-Disposition", "attachment; filename=" + zipFileName + ";");
response.TransmitFile(zipFilePath);
response.Flush();
response.End();
最好先显示javascript警报,然后将浏览器重定向到下载URL,不是吗 大致如下:
function alertAndDownload() {
if (!confirm("You are about to be redirected to a file download. This may take a while! Is that ok?")) return;
window.location = "http://yoursite.com/goDownloadTheirThing.aspx";
}
您可能会在添加标题后发送刷新,这会使“保存”对话框弹出得更快…真的。。。。仍然需要向用户显示某种警报!如果你知道文件的大小,你不能把它放在页眉中,那么浏览器应该选择它,并显示下载量与文件大小的进度。