如何在Response.TransmitFile之后调用Response.Redirect [英] how to call Response.Redirect after Response.TransmitFile

查看:186
本文介绍了如何在Response.TransmitFile之后调用Response.Redirect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Response.TrsnsmitFile之后调用response.redirect

how can we call response.redirect after Response.TrsnsmitFile

推荐答案

问题



  • Response.End()之前的 Response.Redirect()将重定向,但永远不会生成该文件。
  • 如果您在之后放置 Response.Redirect() Response.End(),文件将被生成,但不会重定向。

Problem

  • The Response.Redirect() before the Response.End() will redirect, but the file is never going to be generated.
  • If you put the Response.Redirect() after the Response.End(), the file will be generated, but it will not redirect.


  1. 显示感谢信息在文件生成的开头。

    无论如何,用户已经习惯了,你可以这样说:谢谢。您的下载将在第二个开始。这是最现代的方法。
  2. 请参阅 - 在C#中调用Response.End()后重定向到另一个页面 [ ^ ]


  1. Showing the thank you message at the beginning of the file generation.
    Users are used to this anyway, and you can word it like: "Thanks. Your download will start in a second". This is the most modern approach.
  2. Refer - Redirecting to another page after Response.End() has been called in C#[^]
引用:

我建议添加一个重定向标题。这样的事情:

I suggest to add a redirect header. Something like this:

Response.AddHeader("Refresh", "3; url=index.html");



其中3是时间延迟而index.html是url你需要重定向到


Where 3 is time delay and index.html is url you need to redirect to




这篇关于如何在Response.TransmitFile之后调用Response.Redirect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆