You can return the address of file using ViewModel or ViewData from your action, and use window.location.href
as demonstrated 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>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…