Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Created Issue: Allow FileResult that opens files with FileShare.ReadWrite [571]

$
0
0
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;
}


Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>