public ActionResult DownLoadSubmission(int NodeNo) { if (NodeNo > 0) { DataSet ds = DAL.GetDataSet(" select * from Wroks Where NodeNo="+ NodeNo); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { // DownLoadResult obj = new DownLoadResult(ds.Tables[0].Rows[0]["ActualFileName"].ToString(), ds.Tables[0].Rows[0]["ServerFileName"].ToString()); return new DownLoadResult{FileDownLoadName= ds.Tables[0].Rows[0]["ActualFileName"].ToString(),FileServerName= ds.Tables[0].Rows[0]["ServerFileName"].ToString()}; } } return new EmptyResult(); //return Content(""); }
public class DownLoadResult : ActionResult { public string FileDownLoadName { get; set; } public string FileServerName { get; set; } public DownLoadResult() { } public DownLoadResult(string orgName, string serverName) { this.FileDownLoadName = orgName; this.FileServerName = serverName; } public override void ExecuteResult(ControllerContext context) { string Path = "", PhysicalPath = ""; Path = context.HttpContext.Request.ApplicationPath; PhysicalPath = context.HttpContext.Request.MapPath(Path); string strCompletePath = ""; strCompletePath = PhysicalPath + "Submissions\\" + FileServerName; context.HttpContext.Response.AddHeader("content=disposition", "attachment;filename=" + FileDownLoadName); context.HttpContext.Response.TransmitFile(strCompletePath); } }
$("#tblWorkList").on("click", "a.download", function (e) { debugger e.preventDefault(); var url="@Url.Action("DownLoadSubmission", "Home", new { NodeNo = "-11" })"; url=url.replace("-11",$(this).attr("data-submissionid")) window.location.href = url; });
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)