You can return the file address using ViewModel or ViewData from your action and use window.location.href , as shown in the following code at the end of your view.
controller
public ActionResult Index() { ViewBag.FileName = "{FileName}"; return View(); } public ActionResult Download(string id) { return File("{Path}", "{MIME type}", "{Desired file name}"); }
Markup
<script type="text/javascript"> window.location.href = "/home/download/" + "@Ajax.JavaScriptStringEncode(@ViewBag.FileName)"; </script>
source share