VB.net 文件下载阻止回发
我想生成一个(报告)文件供用户下载,然后向用户显示一条消息以显示该过程已成功完成。
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"
但是,当我使用创建“另存为”框时,它似乎根本停止显示消息。这是为什么?谁能建议一种解决方法?
I want to generate a (report) file for users to download, then display a message to users to show the process completed successfully.
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"
However, when I use create a "save as" box, it seems to stop the message appearing at all. Why is that? And can anyone suggest a way around it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来这是一个很常见的问题。但对于我遇到的所有建议,似乎很少有人提供任何解决方案。 这是 Rick Strahl 博客中的一篇有用的文章。
一种有用的方法是 MyWebClient.DownloadFile。这可以正常下载文件,但不会根据需要提供“另存为”对话框。
It seems this is quite a common problem. But for all the suggestions I've come across, few seem to offer any sort of solution. Here's a useful article in Rick Strahl's blog.
One useful method is MyWebClient.DownloadFile. This downloads the file ok, but doesn't give a "save as" dialogue box as required.