Beispiel #1
0
        public ActionResult DownloadData(string type, int?id)
        {
            var asset = assets.GetById(id);

            if (id == null || asset == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            FileDataBase fileData = new FileDataHandler();

            byte[] downFile = new byte[0];

            if (type == "xml")
            {
                downFile = fileData.GetXmlFile(asset);
            }

            if (type == "txt")
            {
                downFile = fileData.GetTXTFile(asset);
            }

            var filename = Regex.Replace(asset.Title, @"[^a-zA-z0-9]+", String.Empty) + "." + type;

            return(File(downFile, System.Net.Mime.MediaTypeNames.Application.Octet, filename));
        }