title: .NET Core WebAPI - Allow user to download file
body: <p>What I want to do is that when the web client calls the endpoint, the browser then download the file. Basically, just a download file capability. How would I achieve that? </p>
  
  <p>On my API controller, I have tried these 2 functions, and none of them are prompting the browser to download the file. I tested them on Swagger.</p>
  
  <pre><code>    [HttpGet]
      public ActionResult Download()
      {
          var path = @"C:\Users\farid\Desktop";
          return PhysicalFile(path, "text/plain", "Test.txt");
      }
  
      [HttpGet]
      public IActionResult GetBlobDownload()
      {
          var content = new FileStream(
              @"C:\Users\farid\Desktop\Test.txt",
              FileMode.Open,
              FileAccess.Read,
              FileShare.Read);
          var contentType = "text/plain";
          var fileName = "testfile.txt";
          return File(content, contentType, fileName);
      }
  </code></pre>
  
  <p>Or this will not work if using API only? Do I need to test this using a client side application? The web application is on ASP.NET MVC.</p>
  
  <p>If there is any tutorial to allow user to download file in .NET Core, please give them to me. I have Googled a few and none of them are working (or my understanding is totally wrong).</p>