title: Download/Stream file from URL - asp.net
body: <p>I need to stream a file which will result in save as prompt in the browser.
  The issue is, the directory that the file is located is virtually mapped, so I am unable to use Server.MapPath to determine it's actual location. The directory is not in the same location (or even phyical server on the live boxes) as the website.</p>
  
  <p>I'd like something like the following, but that will allow me to pass a web URL, and not a server file path.</p>
  
  <p>I may have to end up building my file path from a config base path, and then append on the rest of the path, but hopefully I can do it this way instead.</p>
  
  <pre><code>var filePath = Server.MapPath(DOCUMENT_PATH);
  
  if (!File.Exists(filePath))
      return;
  
  var fileInfo = new System.IO.FileInfo(filePath);
  Response.ContentType = "application/octet-stream";
  Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", filePath));
  Response.AddHeader("Content-Length", fileInfo.Length.ToString());
  Response.WriteFile(filePath);
  Response.End();
  </code></pre>