Download Now (V3) [your_file_ready_to_download]
Click Here ===== https://shoxet.com/2tFPSw
When Response.End() is called, you will no longer get a response back from the server because Response.End() throws an exception by nature and you can do nothing about it. What you need to do is switch the order. Once you have your file ready to download, use ScriptManager to register a script that does __doPostBack with a particular argument. Later in Page_Load you will read that argument and execute the download accordingly. Meanwhile, after ScriptManager.RegisterStartupScript (or ScriptManager.RegisterClientScriptBlock), Do your clean up logic.
Now your next question will be: Is that the 'neatest' possible way to do it? Basically, if you insist on having everything on the same page then yes you'll have to implement such a workaround. However, the general trend is to open up another tab (new page) that only does the download. One popular example is Microsoft website. Check how you download .NET Framework here. 781b155fdc