Hi Ruben12345,
Check this example. Now please take its reference and correct your code.
Controller
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
[HttpPost]
public FileResult DownloadFile()
{
var sDocument = Server.MapPath("~/UploadedFiles/") + "Sample.xlsx";
byte[] fileBytes = System.IO.File.ReadAllBytes(sDocument);
string fileName = "Sample.xlsx";
return File(fileBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName);
}
}
View
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Index</title>
</head>
<body>
<div>
<% using (Html.BeginForm("DownloadFile", "Home", FormMethod.Post))
{ %>
<input type="submit" value="Download" />
<% } %>
</div>
</body>
</html>
Screenshot
![](https://i.imgur.com/8k8ebMD.jpg)