In asp.net MVC I can do something like the following which will open a stream:
Stream strm1 = GenerateReport(Id);
return File(strm1,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"Report_" + reportId.ToString() + ".xlsx");
Notice how I am passing strm1 which is a stream. I can then name it Report_+ ...xlsx like the example above shows.
Is there a similar way to do this with asp.net web forms using c#.
Or if you have a stream ready to be written, simply copy it to response stream:
Added same code just for visibility
You can use TransmitFile or WriteFile if the file is in your website folder.
Stream
If your data is already in Memory, you want this method which writes the response in chunks.
I use this extension to send a stream as a downloadable file:
And the usage is: