In MVC, we have used following code to download a file. In ASP.NET core, how to achieve this?
HttpResponse response = HttpContext.Current.Response;
my way is quite short and I think it suits most people's need.
[HttpPost]
public ActionResult Download(string filePath, string fileName)
{
var fileBytes = System.IO.File.ReadAllBytes(filePath);
new FileExtensionContentTypeProvider().TryGetContentType(Path.GetFileName(filePath), out var contentType);
return File(fileBytes, contentType ?? "application/octet-stream", fileName);
}