How to download a file through a controller?

Let’s say I have a list of products. I want to put them into a .txt file
and then let the user download it. Is it possible to generate this and
then render it for the user to download? By this I mean a box would come
up asking the user where to save the file, not actually render the
contents in the browser.

Thanks for your help.

I belive that this might help you out: