在mvc中下载文件
public IActionResult MyAction([FromServices] IHostingEnvironment environment )
{
var filePath== System.IO.Path.Combine(environment.WebRootPath, fileName);
string contentType;
new FileExtensionContentTypeProvider().TryGetContentType(filePath, out contentType);
contentType=contentType ?? "application/octet-stream";
return File(System.IO.File.ReadAllBytesAsync(filePath),contentType);
}
File(filePath, MimeMapping.GetMimeMapping(filePath),"errorReport.xlsx");