1

Closed

Allow FileResult that opens files with FileShare.ReadWrite

description

I want to be able to stream application log files to the browser - these files are open for writing, so I need to open them with FileShare.ReadWrite.

I don't like the idea of opening the file in the Controller and using FileStreamResult, as I'm concerned that there is no guarantee the stream will be disposed - see http://stackoverflow.com/questions/12988704/why-isnt-filestreamresult-and-possibly-actionresult-idisposable

It would be nice to have a FilePathResult that opens the file with FileShare.ReadWrite, and the corresponding Controller.File method.

protected internal virtual FilePathResult File(string fileName, string contentType, string fileDownloadName, FileShare share)
{
if (share == FileShare.Read)
{
    FilePathResult result = new FilePathResult(fileName, contentType);
    result.FileDownloadName = fileDownloadName;
}
else
{
    SharedFilePathResult result = new SharedFilePathResult(filename, contentType, share);
    result.FileDownloadName = fileDownloadName;
}
return result;
}
Closed Fri at 5:01 AM by yishaigalatzer
Thanks for reporting this issue.

Looking at the stackoverflow question it looks like it's a purely theoretical concern, assuming you are using the default invoker.

We haven't heard similar feedback from others yet, so unfortunately we decided not to fix it.

comments