I have an ActionResult method in my controller that returns a FileStreamResult for a download file scenario. After the file is downloaded, I would like to redirect the user to a different view. How can I best accomplish this?
Asked
Active
Viewed 3,115 times
2 Answers
1
You can't do it. You can only return one response from your action and that will contain the file. You cannot also put a redirection header in it, best you can do is redirect first, then start the download.

Ufuk Hacıoğulları
- 37,978
- 12
- 114
- 156
-
Thanks! I tried your suggestion to redirect first then start the download but that didn't work. – Mike C Jun 27 '13 at 15:19
0
There's no real easy way to do that, as file downloading is a client/browser thing.
There is a JavaScript technique mentioned here.
TLDR: Create a cookie on the client, override it in the file download (e.g delete it by setting a cookie with a past expiry), keep checking every so often on the client if the cookie is gone, when it is, do a redirect.

RPM1984
- 72,246
- 58
- 225
- 350
-
1I'll give it a try but I think this approach will make it more difficult to maintain and support. – Mike C Jun 27 '13 at 15:20
-
@MikeC - agreed. I don't recommend this approach at all. I agree with Ufuk. But this is a last resort. – RPM1984 Jun 27 '13 at 21:56