Is it possible to get byte[]
from FileResult
in C#?
FileContentResult is an ActionResult that when executed will write a binary file to the response. public FileContentResult DownloadContent() { var myfile = System.IO.File.ReadAllBytes("wwwroot/Files/FileContentResult.pdf"); return new FileContentResult(myfile, "application/pdf");
FileResult is an abstract
class so that won't be the underlying instance type - assuming the correct overload is used then you should be able to cast it to a FileContentResult
if (result is FileContentResult data)
{
var content = data.FileContents;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With