【发布时间】:2017-12-29 06:21:36
【问题描述】:
当我触发加载程序事件以启动加载程序时,当用户单击导出按钮时。哪种方法在客户端使用 jquery 完成。回发发生在我将使用 itextsharp 从 HTML 字符串生成大量 PDF 文档的地方。 毕竟,在客户端浏览器中生成了所有压缩和下载的文件。
我执行以下操作:
Response.AddHeader("Content-Disposition", "attachment; filename=output.zip");
Response.TransmitFile(zipPath);
因为下载后无法停止该加载程序。
服务器端代码背后:
protected void Button1_Click(object sender, EventArgs e)
{
string test = GetImportDetailsPDF("ImportFile(2)_2017.12.19-12.30.24.xlsx");
//Generated all pdf files zipped and downloaded here
string startPath = Server.MapPath("/ImportPdf/");
string zipPath = Server.MapPath("/ImportZip/result.zip");
ZipFile.CreateFromDirectory(startPath, zipPath);
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
Response.ContentType = "image/jpeg";
Response.AddHeader("Content-Disposition", "attachment; filename=output.zip");
Response.TransmitFile(zipPath);
HttpContext.Current.Response.Flush(); // Sends all currently buffered output to the client.
HttpContext.Current.Response.SuppressContent = true; // Gets or sets a value indicating whether to send HTTP content to the client.
HttpContext.Current.ApplicationInstance.CompleteRequest(); // Causes ASP.NET to bypass all events and filtering in the HTTP pipeline chain of execution and directly execute the EndRequest event.
HttpContext.Current.Response.End();
}
public string GetImportDetailsPDF(string FileName)
{
return "Successfully Imported";
}
【问题讨论】:
-
你用的是什么拦截工具……它是如何启动的……jQuery blockui等
标签: c#-4.0 asp.net-4.0