Redirecting to the thank you page and opening the save file dialog immediately

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

I have the following code to display the savefile dialog box:

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();
    }
}

Obviously, this code does not allow the message “Thank you” to be displayed. Is there an “AfterRender” event or something similar on the page where I could move this download code and let the page send a “thank you” message to the user? In the end, I am sincerely grateful to them, so I want to express this.

+5
5

, IFrame

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

DownloadFile.aspx .

+6

META REFRESH :

<META http-equiv="refresh" content="1;URL=http://site.com/path/to/downloadedFile.zip"> 

bodyLoad URL- .

<body onLoad="document.location='http://site.com/path/to/downloadedFile.zip'">

, , JavaScript, ( " ..." ..).

IFRAME, , FRAME (, ). .

+1

, , "" ( ). , "".

+1

"" , . , thankyou.aspx (, , ). js ( ms ).

Then, to maintain the file, you can create a direct link to avoid launching another page on the server; otherwise you must create an HttpHandler to hide the files.

The file must be sent to the client with Response.TrasmitFile

+1
source
0
source

All Articles