title: Download file from REST service in C#
body: <p>I am trying to save a file to the client's machine. I want to require the client to pick the location of the download.</p>
  <p>I have endpoint of the REST service which returns the file to be downloaded. I am trying to set up the code to download the file thats returned from the service with  <em>save as dialog</em>.</p>
  <pre><code>            var Url = &quot;https://randomaddresss/v5/invoices/{&quot; + InvoicesId + &quot;}/getpdfbyid&quot;;
  
              HttpResponse response = HttpContext.Current.Response;
  
              response.ClearContent();
              response.Clear();
  
              response.ContentType = &quot;application/pdf&quot;;
              response.AddHeader(&quot;Content-Disposition&quot;, &quot;attachment; filename=&quot; + InvoicesId + &quot;.pdf;&quot;);
  
              response.TransmitFile(Url);
  
              response.Flush();
              response.End();
  </code></pre>
  <p>The error thats returned is on the line <code>response.TransmitFile(Url);</code> :</p>
  <blockquote>
  <p>'https:/randomaddresss/v5/invoices/2131231231231312/getpdfbyid'
  is not a valid virtual path.</p>
  </blockquote>