asp.net – 使用响应对象生成PDF时的预加载器

我正在使用响应对象生成PDF.代码实际上将
HTML呈现为PDF. PDF生成时间不固定,因此我想在此期间使用Ajax显示预加载器进程(处理/加载).

当我按下按钮启动PDF生成过程时,它将启动预加载器进程,但在生成完PDF后,预加载器进程不会停止.

另外,假设我想清除页面上文本框中的数据,那么就不会被清除.

我需要做些什么才能解决这些问题.

这是代码:

Dim Response As System.Web.HttpResponse = System.Web.HttpContext.Current.Response
Response.Clear()
Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "application/pdf"
Response.AppendHeader("Content-Disposition", "attachment; filename=" + Me.txtReportSetPDFName.Text.Replace(" ", "_") + ".pdf")
Response.AppendHeader("Content-Length", FileLen(sFilePath).ToString)
Response.WriteFile(sFilePath)

最佳答案 你正在用吗

response.End();

如果是,那么您需要在调用之前清除文本框并停止加载程序

response.End();

希望能帮助到你.
如果它解决了你的问题,不要忘记投票.
谢谢.. :)

点赞