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
<
I used this answer posted by @Tieson T to come up with this solution
public FileResult Download()
{
var fileName = $"{V9.Version}.exe";
var filepath = $"Downloads/{fileName}";
byte[] fileBytes = System.IO.File.ReadAllBytes(filepath);
return File(fileBytes, "application/x-msdownload", fileName);
}
The view is now
<a asp-action="Download" asp->
Download
@Ageonix was also correct about not requiring the ~ to get to wwwroot
I'm not somewhere where I can try it, but would something like this do the trick?
<a href="<%= Url.Content('~/Downloads/{ V9.Version}.exe') %>"> Download </a>