3.11.2013

Download Any File Type in ASP.NET MVC 4 FileResult

Just simply specify a generic Octet stream as the contentType:
        public FileResult Download(string filename) {
            filename = Server.HtmlEncode(filename);
            string filePath = ConfigurationManager.AppSettings["SignatureFilesPath"];
            string contentType = System.Net.Mime.MediaTypeNames.Application.Octet;
            return File(Path.Combine(filePath, filename), contentType, filename);
        }

No comments:

Post a Comment