简体   繁体   中英

How to redirect to another page after csv file download?

I have download button which after download i want to redirect to another page.

Response.ContentType = "application/pdf";
                 Response.AddHeader("Content-Disposition", "attachment; filename=downloadfile.pdf");
                 Response.TransmitFile(Server.MapPath("downloadfile.pdf"));
                 Response.AddHeader("Refresh", "3;URL=redirectpage");

This is the code for downloading the file, right now after downloading the file is not redirecting to the page i want to redirect.

Depending on how the request for the file is made, you may want to consider using some client-side code to perform the redirection. A small example of a file download requested from a hyperlink can can be found here:

https://social.msdn.microsoft.com/Forums/sharepoint/en-US/58ff5ed5-c3af-40f9-b136-b0415a0c767c/redirect-after-file-download?forum=sharepointdevelopmentprevious

This example redirects after starting the file download.

You could also redirect then initiate the download as show here (context is with PHP but solution is HTML-based and JS-based)

PHP generate file for download then redirect

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM