【问题标题】:How to redirect to another page after csv file download?csv文件下载后如何重定向到另一个页面?
【发布时间】:2018-03-21 20:17:55
【问题描述】:

我有下载按钮,下载后我想重定向到另一个页面。

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

这是下载文件的代码,现在下载文件后没有重定向到我要重定向的页面。

【问题讨论】:

    标签: c# response.redirect


    【解决方案1】:

    根据文件请求的方式,您可能需要考虑使用一些客户端代码来执行重定向。可以在此处找到从超链接请求的文件下载的小示例:

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

    此示例在开始文件下载后重定向。

    您也可以重定向然后启动下载,如下所示(上下文使用 PHP,但解决方案基于 HTML 和 JS)

    PHP generate file for download then redirect

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-01
      • 2015-07-26
      • 1970-01-01
      相关资源
      最近更新 更多