title: opening a PDF incompletely in CHROME
body: <p>I tried to get a pdf file opened in chrome but it seems to be stuck in the middle of somewhere during displaying process. The code seems to work because it can get PDF opened in IE, not sure why it got stuck in chrome. The screen will just grey out, show the "LOADING" sign, and stop at 7/8. The file is around 6MB or more.</p>
  
  <pre><code>    public static void ReturnPDF(byte[] contents)
      {
          var response = HttpContext.Current.Response;
  
          response.Clear();
          response.AppendHeader("Content-Disposition", "inline;filename=" + "abc.pdf");
  
          response.BufferOutput = true;
          response.ContentType = System.Net.Mime.MediaTypeNames.Application.Pdf;
          response.BinaryWrite(contents);
  
          response.Flush();
          response.Close();
  
          response.End();
      }
  </code></pre>
  
  <p>Any thoughts? Thanks</p>
  
  <p>[UPDATE]</p>
  
  <p>I tried firefox with version 30.0 and it WORKS. My IE is 8.0.7601.17514, which can also open pdf. My Chrome is 39.0.2171.95. Not sure wheather the version of the browser matters or not, here only chrome fails to open the inline PDF...</p>
  
  <p>[SOLVED]</p>
  
  <p>After adding content-length, chrome can open the inline PDF.   </p>
  
  <pre><code>   public static void ReturnPDF(byte[] contents)
      {
          var response = HttpContext.Current.Response;
  
          response.Clear();
          response.AppendHeader("Content-Disposition", "inline;filename=" + "abc.pdf");
  
          //After adding Content-Length, chrome is able to open PDF inline
          response.AppendHeader("Content-Length", contents.Length.ToString());
  
          response.BufferOutput = true;
          response.ContentType = System.Net.Mime.MediaTypeNames.Application.Pdf;
          response.BinaryWrite(contents);
  
          response.Flush();
          response.Close();
  
          response.End();
      }
  </code></pre>