title: MVC json vs. ActionLink
body: <p>new to programming.  I am trying to print a PDF from MVC, it works well if I use Action Link, here is my code:</p>
  
  <pre><code>  &lt;%= Html.ActionLink("Print","GeneratePdf","Home", new { fc="Test" },null) %&gt;
  
     public ActionResult GeneratePdf(string fc)
          {
              Document document = new Document();
              MemoryStream workStream = new MemoryStream();
              PdfWriter.GetInstance(document, workStream);
              document.Open();
              document.Add(new iTextSharp.text.Paragraph("\n\n"));
              // need to add the user name
              iTextSharp.text.Paragraph p = new iTextSharp.text.Paragraph("Name: " + fc);
              p.Alignment = 1;
              document.Add(p);
  
              document.Close();
              byte[] byteInfo = workStream.ToArray();
              SendPdfToBrowser(byteInfo);
              return null;
          }
  
     public void SendPdfToBrowser(byte[] buf)
          {
              string filename = "Certificate.pdf";
  
              // Prepare the headers.
              Response.ClearContent();
              Response.ClearHeaders();
              Response.ContentType = "application/pdf";
              Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
  
              // Write the PDF data.
              Response.BinaryWrite(buf);
  
              // Flush the buffer to the browser.
              Response.End();
              Response.Flush();
              Response.Clear();
          }
  </code></pre>
  
  <p>I need to use Json, here is the code:</p>
  
  <pre><code>function PrintChart(fc) {
  
                   var fc = "Test";
                   var url = '&lt;%= Url.Content("~/Home/GeneratePdf") %&gt;';
                   $.post(url, { fc: fc },
              function (content) {
                  if (content != null) { 5 }
              }, "json");
  
   &lt;input type="button" onclick="PrintChart();" value="Print" /&gt;
  </code></pre>
  
  <p>I don't get any errors but it does not generate the PDF file.  Thanks in advance.</p>