Reputation: 1
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?
Upvotes: 0
Views: 3146
Reputation: 73112
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.
Upvotes: 0
Reputation: 38468
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.
Upvotes: 1