Reputation: 41
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.
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();
Upvotes: 0
Views: 3908
Reputation: 1
I did stumbled upon this 'Use Double quotes so documents with comma in the filename is ok in Chrome Response.AddHeader("Content-Disposition", "attachment;filename=""" + myfile.Filnavn & "")
Maybe double quotes is necessary for Chrome
Upvotes: 0
Reputation: 151588
You cannot reliably, cross-browser, push a file to the client and then redirect in one HTTP response.
Just create a landing page that shows what you want to show, and let that page (redirect to the) download.
Upvotes: 1
Reputation: 302
Use this code
Response.ClearContent();
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Upvotes: 0