BenefitsAllocationUpload.Controllers.ReportsController.Download C# (CSharp) Method

Download() public method

public Download ( string id ) : System.Web.Mvc.ActionResult
id string
return System.Web.Mvc.ActionResult
        public ActionResult Download(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                TempData["Message"] = "Unable to download file.  No file was selected. Please select a file in order to download file.";
                return HttpNotFound();
            }

            var file = GetNamedFile(id);

            var filename = file.FileName;
            var filePathAndFilename = file.FilePath;

            const string contentType = "application/text";
            //Parameters to file are
            //1. The File Path on the File Server
            //2. The content type MIME type
            //3. The parameter for the file save by the browser
            return File(filePathAndFilename, contentType, filename);
        }