Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I am using following code for downloading file and after downloading file its opens my site page, but its working only in Firefox browser.

Its not working in other browsers.
C#
Response.AddHeader("Refresh", "3; url=http://www.mysite.com/");
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename=myfile.pdf");
Response.TransmitFile(Server.MapPath("myfile.pdf"));
Response.End();
Posted
v2

I think your problem is that the browsers dont support the refresh response header for application/octet-stream responses.

I found the best solution if you need a page load after a download is to put the download into a hidden iframe.
 
Share this answer
 
Follow my previous answer on same type of question.
how to call Response.Redirect after Response.TransmitFile[^]

As the second method is browser dependent, so better go for the first approach, which is implemented in many modern websites these days.
 
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