title: C# MVC website PDF file in stored in byte array, display in browser
body: <p>I am receiving a <code>byte[]</code> which contains a PDF.</p>
  
  <p>I need to take the <code>byte[]</code> and display the PDF <strong>in the browser</strong>. 
  I have found similar questions like this - <a href="https://stackoverflow.com/questions/1510451/how-to-return-pdf-to-browser-in-mvc">How to return PDF to browser in MVC?</a>.
  But, it opens the PDF in a PDF viewer, also I am getting an error saying the file couldn't be opened because it's - "not a supported file type or because the file has been damaged".</p>
  
  <p>How can I open the PDF in the browser? My code so far looks like the following -</p>
  
  <pre><code>    public ActionResult DisplayPDF()
      {
          byte[] byteArray = GetPdfFromDB();
          Stream stream = new MemoryStream(byteArray);
          stream.Flush(); 
          stream.Position = 0; 
  
          return File(stream, "application/pdf", "Labels.pdf");
      }
  </code></pre>