I cannot find a reference to downloading a file using MVC Core.
We have a single exe file for members to download from our website. In the past we have put
<a href=(file path)> Download < /a>
for our users to click. I would like to do something equivalent in MVC Core along the lines of
<a href=@ViewData["DownloadLink"]> Download < /a>
with DownloadLink populated with the file path.
public class DownloadController : Controller
{
[HttpGet]
public IActionResult Index()
{
ViewData["DownloadLink"] = ($"~/Downloads/{V9.Version}.exe");
return View();
}
}
`
The link <a href=@ViewData["DownloadLink"]> Download < /a>
gets the correct path, but when clicked only renders the path in the address bar. Is there a simple way to set a download link?