In this article I will explain with an example, how to download File in ASP.Net Core (.Net Core 10) with Entity Framework Core in Visual Studio 2026.
The File will be stored in a Folder (Directory) on Server.
Note: For beginners in ASP.Net Core (.Net Core 10), please refer my article ASP.Net Core 10: Hello World Tutorial with Sample Program example.
 
 

Software Information

This article makes use of Visual Studio 2026 and .Net Core 10.
 

Folder (Directory) Location

The Folder (Directory) is located within the Project inside the wwwroot folder. Below is the screenshot of the Solution Explorer window where you can see the Folder (Directory) i.e. Files and it containing three files.
.Net Core 10: Download File in ASP.Net Core
 

Controller

The Controller consists of two Action methods.

Action method for handling File Display operation

Inside this Action method, simply the View is returned.
 

Action method for handling File Download operation

This action method handles the File Download operation and when the ActionLink is clicked, the name of the File to be downloaded is sent to this method.
First, the File’s path is generated by combining the Directory.GetCurrentDirectory(), wwwroot and the Files folder which contains the Files to be downloaded.
Then the File is read as Binary Data into a Byte Array object using the ReadAllBytes method of the File class.
And then the Byte Array object is sent for download using the File function.
public class HomeController  : Controller
{
    public IActionResult Index()
    {
       return View();
    }
 
    public IActionResult DownloadFile(string fileName)
    {
       //Build the File Path.
       string path  Path.Combine(Directory.GetCurrentDirectory(),"wwwroot","Files",fileName);
 
       if (System.IO.File.Exists(path))
       {
           //Read the File data into Byte Array.
           byte[]bytes  System.IO.File.ReadAllBytes(path);
 
           //Send the File to Browser.
           return File(bytes,"application/octet-stream",fileName);
       }
       else
       {
           return NotFound();
       }
    }
}
 

View

The HTML Table contains an ActionLink for downloading the File.
When the Download link is clicked, the ActionLink calls the DownloadFile Action method and the File is downloaded.
@{
   Layout =  null;
}
 
<!DOCTYPE html>
 
<html>
<head>
   <meta name="viewport" content="width=device-width" />
   <title>Index</title>
   <style type="text/css">
       body  {font-family:Arial;font-size:10pt; }
   </style>
</head>
<body>
     @Html.ActionLink("Download""DownloadFile"new  {fileName  "Mudassar_Khan.pdf" })
</body>
</html>
 
 

Screenshot

.Net Core 10: Download File in ASP.Net Core
 

Testing Log

Compiled in: Visual Studio 2026
Framework: .Net Core 10.
Result: 100% Success
 
 

Downloads