Hi Below code using to Bind File down load in MVC, BUT its working local, when i am hosting its not working properly.
below refrence i used
public ActionResult ViewSummarylist(string id)
{
string Project = Request.QueryString["Project"];
string Vendor = Request.QueryString["Vendor"];
OEMEntry objoem = new OEMEntry();
DataAccessLayer objds = new DataAccessLayer();
string Type = "D";
objoem.GetSummary = objds.ViewSummaryPartialList(id, Project, Vendor);
return View(objoem);
}
public ActionResult Download()
{
string[] files = Directory.GetFiles(Server.MapPath("/File"));
for (int i = 0; i < files.Length; i++)
{
files[i] = Path.GetFileName(files[i]);
}
ViewBag.Files = files;
return View();
}
[HttpGet]
public FileResult DownloadFile(string id)
{
var filepath = System.IO.Path.Combine(Server.MapPath("/File/"), "Employee Active Details.xlsx");
return new FilePathResult(filepath, "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
}
<table class="table table-striped custom-table table-hover" border="1">
<thead>
<tr>
<th style="align-content:center"> S.No</th>
<th> Date</th>
<th>From Time</th>
<th>To Time</th>
<th>Summary of Work Excuted</th>
<th>File</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.GetSummary)
{
<tr>
<td>
@Html.DisplayFor(modelitem => item.UniqueID)
</td>
<td>
<a href="#">@Html.DisplayFor(modelitem => item.CrDate)</a>
</td>
<td>
@Html.DisplayFor(modelitem => item.Fromtime)
</td>
<td>@Html.DisplayFor(modelitem => item.ToTime)</td>
<td style="width:350px">
@Html.DisplayFor(modelitem => item.OemRepr)
</td>
<td>
<i>@Html.ActionLink("Download", "DownloadFile", new { id = item.FolderPath }) </i>
</td>
</tr>
}
</tbody>
</table>