开发者

Download File and send email in asp.net

开发者 https://www.devze.com 2023-02-15 23:00 出处:网络
How to exceute code after response.redirect? I want to force file download using response开发者_如何学Go.redirect , once the file is downloaded i wanted to show modal pop up to send email.

How to exceute code after response.redirect? I want to force file download using response开发者_如何学Go.redirect , once the file is downloaded i wanted to show modal pop up to send email.

but after response.redirect the popup is not getting called. Pls help me how to do this,

Thanks

UPDATE:

Thanks for your reply. I am doing like this. any suggestions?

Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName.Name);
                long FileSize = myFile.Length;
                byte[] Buffer = new byte[(int)FileSize];
                myFile.Read(Buffer, 0, (int)FileSize);
                myFile.Close();

                Response.BinaryWrite(Buffer);
                // Response.Redirect(filepath,false);
                Response.Flush();
                Response.Close();
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowPopup", "window.setTimeout('PopupModal()',50);", true);


You can't, unless the code you wish to execute is called on entering the location specified when using Response.Redirect. Once you transfer control, that's it, you end the response - the executing context is no longer and wherever you have transferred to takes over.

If you want to push a file down the wire, take a look at Response.WriteFile instead, this way you can have them download the file and continue executing your code, all within a single page, or at least transferring control between pages which carry specific actions; here's the MSDN link for more information.

0

精彩评论

暂无评论...
验证码 换一张
取 消