Last active
June 9, 2017 03:48
-
-
Save johnmmoss/8ee16837513ab69de4f3 to your computer and use it in GitHub Desktop.
ASP.NET MVC FileStreamResult Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /File/Stream | |
public FileStreamResult Stream() | |
{ | |
var fileContent = new byte[] { Ascii.one, Ascii.Comma, Ascii.two, Ascii.Comma, Ascii.three }; | |
var stream = new MemoryStream(fileContent); | |
var fileStreamResult = new FileStreamResult(stream, mimeType); | |
fileStreamResult.FileDownloadName = "FileStreamExample.csv"; | |
return fileStreamResult; | |
} | |
// File/Stream2 | |
public FileStreamResult Stream2() | |
{ | |
byte[] fileContent = new[] { Ascii.one, Ascii.Comma, Ascii.two, Ascii.Comma, Ascii.three }; | |
return File(new MemoryStream(fileContent), mimeType); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment