I have an ASP.Net WebForm that dynamically generates a pdf. The pdf download works in all the desktop browsers, as well as the IPad, Chrome mobile, and Firefox mobile. However, the pdf download fails in the Android browser with the message "Download Unsuccessful" in the notification area. I am writing the pdf to the response with this code:
using (PdfDocument pdf = this.RenderPDF())
using (MemoryStream stream = new MemoryStream())
{
pdf.Save(stream, false);
response.Clear();
response.AddHeader("content-disposition", "inline;filename=myPdf.pdf");
response.AddHeader("content-length", stream.Length.ToString());
response.ContentType = "application/pdf";
response.BinaryWrite(stream.ToArray());
response.Flush();
stream.Close();
response.End();
}
What should I do differently to get the pdf download working in the Android browser?