public FileResult Download(string name, string name2) { Stream file = null; if (ftp.FTPDownload(name, out file)) { return(File(file, MediaTypeNames.Application.Octet, name2)); } else { return(null); } }
public FileResult Download(string name, string name2) { //string path = Server.MapPath("~/signalr/Servicios/" + name); //byte[] fileBytes = System.IO.File.ReadAllBytes(path); //return File(fileBytes, MediaTypeNames.Application.Octet, name); Stream file = null; if (ftp.FTPDownload(name, out file)) { return(File(file, MediaTypeNames.Application.Octet, name2)); } else { return(null); } }
public ActionResult Download(string path, string file) { var Result = FTPHelper.FTPDownload(path, file); var provider = new FileExtensionContentTypeProvider(); provider.Mappings.Add(".dnct", "application/dotnetcoretutorials"); string contentType; if (!provider.TryGetContentType(file, out contentType)) { contentType = "application/octet-stream"; } System.Net.Mime.ContentDisposition cd = new System.Net.Mime.ContentDisposition { FileName = Result.FileName, Inline = false // false = prompt the user for downloading; true = browser to try to show the file inline }; Response.Headers.Add("Content-Disposition", cd.ToString()); Response.Headers.Add("X-Content-Type-Options", "nosniff"); return(File(System.IO.File.ReadAllBytes(file), contentType)); }