Click here to Skip to main content
16,017,650 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a asp button, on clicking button my file is downloading but i need to postback the page or redirect a page after file is downloaded.

i have already used
1.Response.AddHeader("Refresh", "3;URL=frmDashboard.aspx");
2.Removed response.end(),response.flush(),response.close();
but still not getting postback


please help me

What I have tried:

string filePath = "E:\\FileName.docx;         
           Response.ContentType = ContentType;
           Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(filePath));
           Response.WriteFile(filePath);
           Response.Flush();
           HttpContext.Current.ApplicationInstance.CompleteRequest();
           Response.Close();
Posted
Updated 15-Sep-16 1:19am

Refer my Tip/Article and just modify the code as below

ASP.NET Export Excel - Javascript event after download[^]

var loop = setInterval(function () {
         if (IsCookieValid()) {
             document.getElementById('imgloadinggif').style.display =  'none'; clearInterval(loop)
             // your code here..
             window.location.reload(); // reload the page
         }

     }, timeInterval);
 
Share this answer
 
v2
When the user requests the page that downloads the file you can only send one response, and that response is the file stream for the client to download. The download itself is handled by the user's browser and you don't know if the file has been downloaded or not. Add to that if you want to do a redirect that is also a response and as above you can only send one response...a download or a redirect, you can't do both.

So basically you just can't do this.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900