title: Desktop web site can't open pdf file on mobile devices - how to
body: <p>VS2010 VB.NET ASP.NET</p>
  
  <p>I have a simple site where the user clicks a button and a pdf file is displayed in a new broswer window.</p>
  
  <p>To do the this a button launches a new browser window with the following code in the page load event:</p>
  
  <pre><code>            Response.Clear()
              Response.ClearContent()
              Response.ClearHeaders()
  
              Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1))
              Response.Buffer = True
  
              Response.ContentType = "application/pdf"
              'Response.ContentType = "text/plain"
  
              If Download_Flag Then
                  'force SaveAs  (this is the download option)
                  Response.AppendHeader("Content-Disposition", "attachment; filename=" &amp; "myfile" &amp; ".pdf")
              Else
                  'open in borwser
                  Response.AddHeader("Content-Disposition", "inline")
              End If
  
              Response.OutputStream.Write(PdfBuffer, 0, PdfBuffer.Length)
              Response.OutputStream.Flush()
              Response.OutputStream.Close()
              Response.End()
  </code></pre>
  
  <p>PDFBuffer is a byte array containing the pdf document</p>
  
  <p>This code displays the pdf file in the browser (ie, chrome, mozilla, safari?) using whatever pdf plugin is installed.</p>
  
  <p>if download_flag is true then the pdf is not opened in the viewer but instead browser prompts with the save file dialog</p>
  
  <p>As I said, this code works in desktop borwsers, but it does not work on an ipad or an android phone, and propably other devices as well.</p>
  
  <p>The site is not mobile aware, but if need be it could, I suppose.</p>
  
  <p>I know that apple does not allow downloads, and android may not be able to open open an additional window, so how can I open a pdf file on a button click on these devices?  I know he ipad and the android can both open pdf files, I've done it on other sites.</p>