title: How to return a PDF in an action result in MVC
body: <p>I have a little problem getting my head around this problem. I have an ajax call that should render an iframe which loads a PDF.  The PDF is generated using Apache FOP hosted in another environment. What I have so far is:</p>
  
  <p>in the controller action (where the src element of the iFrame points), the code snippet is:</p>
  
  <pre><code>var targetStream = new MemoryStream();    
  using (var response = FOPrequest.GetResponse()) // response from FOP
                  {
                      using (var stream = response.GetResponseStream())
                      {
                          stream.CopyTo(targetStream);
  
                      }
                  }
   return new FileStreamResult(targetStream, "application/pdf");
  </code></pre>
  
  <p>However, this does not work as expected. The stream is populated as expected, but the PDF does not render in the iFrame.
  I get a Http response code of 200 (OK).</p>
  
  <p>I'd be grateful of any help.</p>