title: How to send a file to a client so a Download dialog will open?
body: <p>I have a file, say a PDF on my website and when a user visits a page I want to display a download dialog for the pdf on page load or a button click.</p>
  
  <p>I did a google search and I found two ways to do this but wondering what is the accepted way of doing this?  I am currently doing this</p>
  
  <pre><code>string pdfPath = MapPath("mypdf.pdf");
  Response.ContentType = "Application/pdf";
  
  
  Response.AppendHeader( "content-disposition",
          "attachment; filename=" + name );
  Response.WriteFile(pdfPath);
  Response.End();
  </code></pre>
  
  <p>(Code was based off code from <a href="http://aspalliance.com/259" rel="nofollow noreferrer">http://aspalliance.com/259</a>, also found code from 
  <a href="http://www.west-wind.com/weblog/posts/76293.aspx" rel="nofollow noreferrer">http://www.west-wind.com/weblog/posts/76293.aspx</a>)</p>