I am transmitting a PDF to an MVC controller, saving the PDF to a database, and retrieving it. If I save the PDF to disk on the server side (prior to returning a file result), it looks fine. However, when I do something akin to the following:
return File(fileBytesFromDB, "application/pdf", "file.pdf");
and try to view it from a browser (any browser), the PDF appears to be corrupt. In fact, it’s an entirely different size.
What have I missed?
I found it. One of my coworkers had added in a tokenizer as a decorator of return actions, and it was tokenizing the file stream. I added some logic to ignore
FileStreamResultandFileContentResultand now the PDFs come out okay.