Last active
February 19, 2019 05:22
-
-
Save scottsauber/1a7ed4a21b37280bdc44eeef2a4af8bc to your computer and use it in GitHub Desktop.
This file contains 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
[Route("File")] | |
public class FileController : Controller | |
{ | |
[HttpPost("Download/{id:guid}")] | |
[ValidateAntiForgeryToken] | |
public async Task<IActionResult> Download(Guid id) | |
{ | |
// Grab a test.pdf back one directory. Look ma - it even runs on Linux with Path.DirectorySeparatorChar! | |
var fileContent = await File.ReadAllBytesAsync($"..{Path.DirectorySeparatorChar}test.pdf"); | |
return File(fileContent, "application/pdf") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment