In PHP, it is possible to return a file to the browser by echoing it out with the correct header. You do not need to save a copy of it prior on the server.
So assuming I have a bunch of data I wish to return as a excel file – after creating the data structure using OpenXML, how can I serve the file to the user without saving it on the server first?
Write your data to a stream and return it from your controller action method in a FileStreamResult by setting the
FileStream,ContentTypeandFileDownloadNameproperties.Update:
A short cut for doing this, is to use the Controller.File() method.