title: What is the difference between File(), PhysicalFile(), PhysicalFileResult() in ASP.NET Core?
body: <p>I am trying to build a Web API endpoint using ASP.NET core 3.1 what would allow an application to send me an id, and the response would be with the corresponding file.</p>
  
  <p>Here is my method</p>
  
  <pre><code>[HttpGet("get")]
  public IActionResult Get(Guid id)
  {
      FoundFileInfo file = PathFinder.Get(id);
  
      if(file == null || !System.IO.File.Exists(file.Fullname))
      {
          return NotFound();
      }
  
      return File(file.Fullname, "image/jpeg");
  }
  </code></pre>
  
  <p>using the same code, I can return <code>File(file.VirtualName, "image/jpeg")</code>, <code>new PhysicalFileResult(filename, "image/jpeg")</code>, or <code>PhysicalFile(filename, "image/jpeg")</code>. But what is the difference between them and what is the right use case for each?</p>
  
  <p>My end goal is to allow the consumer to construct an instance of <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.fileproviders.ifileinfo?view=dotnet-plat-ext-3.1" rel="noreferrer">IFileInfo</a> from the response of my endpoint. Somehow I would want to give the consumer enough info like <code>LastModified</code>, <code>Length</code>, <code>Name</code>, <code>PhysicalPath</code>. Which method is the right method to use for my case? </p>