Downloading File in ASP.NET Core MVC
<p>Completely new on .Net core from MVC5, so how does download file works with .NET Core? I have tried writing down code but it has errors. Thanks in advance to the helpers.</p>

<p>Controller       </p>

<pre><code>public ActionResult Download()
    {
        string[] files = Path.Combine(_hostingEnvironment.WebRootPath, "uploads");
        for (int i = 0; i &lt; files.Length; i++)
        {
            files[i] = Path.GetFileName(files[i]);
        }
        ViewBag.Files = files;
        return View();
    }

    public FileResult DownloadFile(string fileName)
    {
        var filepath = Path.Combine(_hostingEnvironment.WebRootPath, "uploads");
        return File(filepath, LineMapping.GetMimeMapping(filepath), fileName);
    }
</code></pre>

<p>View</p>

<pre><code>  &lt;h2&gt;Downloads&lt;/h2&gt;
 &lt;table&gt;
 &lt;tr&gt;
    &lt;th&gt;File Name&lt;/th&gt;
    &lt;th&gt;Link&lt;/th&gt;
 &lt;/tr&gt;
 @for (var i =0; i &lt;= Model.Count -1; i++) {
    &lt;tr&gt;
        &lt;td&gt;
            @Model[i].ToString()
        &lt;/td&gt;
        &lt;td&gt;     
            @Html.ActionLink("Download", "Download", new  { ImageName=@Model[i].ToString() })           
        &lt;/td&gt;
    &lt;/tr&gt;
}
</code></pre>

<p></p>