I have a page where I’m simply trying to write a pdf to the screen. Here’s what I’m doing:
protected void ViewPDF(string url)
{
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.TransmitFile(url);
Response.Flush();
Response.End();
}
This works in every browser and OS except for Firefox on Mac. Instead of displaying the pdf file in the browser, the browser opens the dialog to download the file, where you can Open it or Save it.
I’ve also tried this:
protected void ViewPDF(string url)
{
Response.Clear();
Response.ContentType = "application/pdf";
string path = Server.MapPath(url);
byte[] data = File.ReadAllBytes(path);
Response.BinaryWrite(data);
Response.End();
}
And I get the same result.
Anyone know how to fix this?
The browser needs to be able to render any given file format. Firefox (for Mac) does not include a PDF renderer out of the box. It’s that simple.
See http://support.mozilla.org/en-US/kb/view-pdf-files-firefox-without-downloading-them.