title: How to download file in asp.net core
body: <p>My download method is</p>
  
  <pre><code>public async Task&lt;IActionResult&gt; Download(string filename)
          {
  
              if (filename == null)
                  return Content("filename not present");
  
              var path = Path.Combine(
                             Directory.GetCurrentDirectory(), "wwwroot" + @"\UploadFiles", filename);
  
              var memory = new MemoryStream();
              using (var stream = new FileStream(path, FileMode.Open))
              {
                  await stream.CopyToAsync(memory);
              }
              memory.Position = 0;
              return File(memory, GetContentType(path), Path.GetFileName(path));
          }
  </code></pre>
  
  <p>and view.chtml and route with filepath</p>
  
  <pre><code>&lt;a asp-action="Download"
                     asp-route-filename="@item.UploadFilePath"&gt;
                      Download
                  &lt;/a&gt; 
  </code></pre>
  
  <p>@item.UploadFilePath is database saved path.please help me.</p>