title: Displaying PDF from byte[] in MVC 4
body: <p>I'm using Grid.MVC to display data from an entity model. On row click I am getting the value of a cell and passing it to my controller with a json/ajax function.</p>
  
  <p><a href="https://i.stack.imgur.com/tDkVn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tDkVn.png" alt=""></a></p>
  
  <p>In my controller the int "ticketnumber" is passing just fine. The thing that I am not understanding is when I hard code the int, it is working (if I directly browse to <a href="http://localhost:58779/ticket/PDFVIEW" rel="nofollow noreferrer">http://localhost:58779/ticket/PDFVIEW</a>). </p>
  
  <p><a href="https://i.stack.imgur.com/JxX6c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JxX6c.png" alt="enter image description here"></a></p>
  
  <p>The controller seems to be running through just fine, but it is not displaying the PDF..it just takes me back to my grid in my view with the ajax script. Thanks for the help.</p>
  
  <p>Edit - Code: </p>
  
  <pre><code>   &lt;script&gt;
          $(function () {
              pageGrids.TicketGrid.onRowSelect(function (e) {
                  var ticketnumber = e.row.UnsettledID;
                  ticketnumber = JSON.stringify({ 'ticketnumber': ticketnumber });
                  $.ajax({
                      contentType: 'application/json; charset=utf-8',
                      dataType: 'json',
                      type: 'POST',
                      url: '/ticket/PDFVIEW',
                      data: ticketnumber,
  
                  });
              });
          });
  
      &lt;/script&gt;
  </code></pre>
  
  <p>controller:</p>
  
  <pre><code>[ActionName("PDFVIEW")]
      [HttpGet]
      public ActionResult PDFVIEW(int ticketnumber)
      {
  
          var db = new ScaleTrac_VerticalEntities();
          Ticket_UnsettledScaleImages tu = new Ticket_UnsettledScaleImages();
          tu = db.Ticket_UnsettledScaleImages.Where(p =&gt; p.UnsettledID == ticketnumber).First();
          string filename = "ScaleTick" + tu.UnsettledID + ".pdf";
          {
              byte[] bytes = tu.ScaleTicket;
              TempData["bytes"] = bytes;
              Response.Clear();
              MemoryStream ms = new MemoryStream(bytes);
  
              return new FileStreamResult(ms, "application/pdf");
          }
  
      }
  </code></pre>