title: Download a PDF (not opening it in browser) when clicked
body: <p>I have a href link to a PDF file that when clicked it opens in a new page in browser. I want this to download instead of opening in a new tab. </p>
  
  <p>So how to make a PDF file link downloadable instead of opening them in the browser?</p>
  
  <p>Here's the code:</p>
  
  <pre><code>&lt;asp:FormView ID="FormView2" runat="server"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:LoginView ID="LoginView1" runat="server"&gt;
                      &lt;LoggedInTemplate&gt;
                            &lt;asp:HyperLink ID="HyperLink1" ToolTip="Open" CssClass="button" runat="server" NavigateUrl='&lt;%# Eval("PDFUrl") %&gt;' Text="Open" Target="_blank"&gt;&lt;/asp:HyperLink&gt;
                          &lt;br /&gt;
                      &lt;/LoggedInTemplate&gt;
                      &lt;AnonymousTemplate&gt;
                              &lt;p&gt;You need to log in to view the book.&lt;/p&gt;
                      &lt;/AnonymousTemplate&gt;
                  &lt;/asp:LoginView&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:FormView&gt;
  </code></pre>
  
  <p>Code behind:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      int bookId = Convert.ToInt32(Request.QueryString.Get("BookId"));
  
  
      using (LibraryEntities entities = new LibraryEntities())
      {
          var book = (from r in entities.Books
                            where r.Id == bookId
                            select r);
          FormView2.DataSource = book;
          FormView2.DataBind();
      }
  }
  </code></pre>