using CounsellorBL; using DefenseWeb.Models; using OT.COM.LogisticsUtil; using OT.COM.SignalerMessage; using SoldierData; using SoldierData.syserp; using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Web; using System.Web.Mvc; namespace DefenseWeb.Controllers { public class FileController : Controller { // http://localhost:2180/File/DirectDownload?FilePath=Uploads/a.xls public ActionResult DirectDownload(string FilePath) { ActionResult ar = null; string sMsg = null; try { do { if (FilePath == null || FilePath.Trim().Length == 0) { sMsg = "NO PATH"; break; } string sTestPath = Server.MapPath("~/" + FilePath); if (System.IO.File.Exists(sTestPath) == false) { sMsg = "FILE NOT EXIST"; break; } string[] saPath = FilePath.Split("\\/".ToCharArray()); ar = File(sTestPath, System.Net.Mime.MediaTypeNames.Application.Octet, saPath[saPath.Length - 1]); } while (false); } catch (Exception ex) { sMsg = new Util().GetLastExceptionMsg(ex); } if (sMsg != null) { ar = Content(sMsg); } return ar; } } }