重定向到一个"谢谢"页面,并立即提供下载文件的保存对话框 [英] Redirecting to a "Thank you" page and offering the save dialog of downloaded file immediately

查看:141
本文介绍了重定向到一个"谢谢"页面,并立即提供下载文件的保存对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP.NET2.0。我创建了一些输入字段和下载按钮下载表格。当点击下载按钮,我想将用户重定向到一个感谢您下载...页面,并立即给他/她来保存文件。

I am using ASP.NET2.0. I have created a download form with some input fields and a download button. When the download button is clicked, I want to redirect the user to a "Thank you for downloading..." page and immediately offer him/her the file to save.

我有这样下面的代码显示了saveFile对话框:

I have this following code to show the savefile dialog:

public partial class ThankYouPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    	Response.Clear();
    	Response.AddHeader("Content-Disposition", 
                          "attachment; filename=\"downloadedFile.zip\"");
    	Response.ContentType = "application/x-zip-compressed";
    	Response.BinaryWrite(this.downloadedFileByteArray);
    	Response.Flush();
    	Response.End();
    }
}



显然,这个代码不允许展示任何谢谢你的字样。是否有一个一个AfterRender事件或类似的页面,在这里,我可以移动此下载代码,并给出该页面的机会来渲染谢谢的信息给用户的东西吗?毕竟,我忠实地感谢他们,所以我也想表达的。

Obviously, this code does not allow to display any "Thank you" message. Is there an "AfterRender" event or something similar of the Page where, I could move this download code and give a chance for the page to render the "thank you" message to the user? After all, I am truely thankful to them, so I do want to express that.

推荐答案

您可以引用从下载页面您使用iframe谢谢页

You could reference a download page from your thank you page using an IFrame

<iframe src="DownloadFile.aspx" style="display:none;" />

在这种情况下,DownloadFile.aspx会对后面的代码从你的例子。

In this case, DownloadFile.aspx would have the code behind from your example.

这篇关于重定向到一个&QUOT;谢谢&QUOT;页面,并立即提供下载文件的保存对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆