1

我想生成一个(报告)文件供用户下载,然后向用户显示一条消息以显示该过程已成功完成。

Dim myFile As FileInfo = New FileInfo(<filepath>)

'My function to generate a report (this can take a few minutes)
GenerateReport(myFile.FullName)

'Prompt user with "save as" dialog box.
Response.Clear()
Response.ClearHeaders()
Response.AddHeader("Content-Disposition", "attachment; filename=" & _
Response.WriteFile()

'Give message to say generation is complete. (This line doesn't take effect)
lblMsg.Text = "Generation complete"

但是,当我使用创建“另存为”框时,似乎完全停止了消息的出现。这是为什么?任何人都可以提出解决方法吗?

4

1 回答 1

0

看来这是一个相当普遍的问题。但是对于我遇到的所有建议,似乎很少有人提供任何类型的解决方案。这是 Rick Strahl 博客中的一篇有用的文章

一种有用的方法是MyWebClient.DownloadFile。这可以下载文件,但没有根据需要提供“另存为”对话框。

于 2011-04-15T14:01:06.273 回答