I know that I can return a file from a controller action using code like:
public ActionResult SomeAction()
{
return File(PathToTheFile);
}
There is also an overload that accepts a Stream rather than a file path.
In my case, I dynamically create a CSV file based on a database query. It would be simpler to write that CSV file directly to the response, and have the response treated as a file. Is it possible to do that? How?
EDIT
I assume that I would be writing to some sort of stream, but what kind of stream and who is responsible for disposing it?