I am wondering if you do something like
public FileResult result()
{
Stream stream = new Stream();
return File(stream,"text/html","bob.html");
}
if File() would close the stream for you? Since I tried to put the “stream” in a using statement but it always gave me a error saying the stream was closed.
public FileResult result()
{
using(Stream stream = new Stream())
{
return File(stream,"text/html","bob.html");
}
}
If you are using the
Fileobject to send the resulting file for download as bob.html then yes.I believe that all standard Streams (OutputStream, FileStream, CryptoStream) will attempt to flush when closed or disposed.
There are a number of classes within the MVC framework that implement the base
FileResultclass.