Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Response.ContentType = "Application/pdf";
Response.TransmitFile(pdfReport.Location + pdfReport.FileName);

In IE browser to disable the Open or Save dialogue prompt and view to tag withour PDF Viewer plugin.

Problem Streaming PDF File to IE Browsers-does not have the pdf pluggin in Transmitfile without pdf viewer pluggin.

Thanks in advance.

<b>What I have tried:</b>

if ((Request.Browser.Type.Contains("InternetExplorer")))
{
Response.AppendHeader("Content-Disposition", "FirstCloseReport; filename=" + pdfReport.FileName);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/pdf";
Response.Write(pdfReport.Location + pdfReport.FileName);
Response.Flush();
Response.End();
}
Response.End();
Posted
Updated 23-May-18 8:48am
v2
Comments
F-ES Sitecore 15-May-18 11:17am    
How do you expect the browser to show the PDF is there is no viewer installed? Leave the default behaviour as it is, if the browser can't show the file it will offer it for opening or download and the user can open it if they have another app that can view the file or if they have nothing to view the file they can reject the download or download it to disc and have it sit there with nothing to view it.

Your question is like asking "How do I force someone to understand French when they only know English".
Shekar Raja 15-May-18 11:27am    
The main issue Internet Explorer browser doesn't have the PDF viewer/Plug in without using to configure(any viewer dll) the PDF file in tag to avoid the Open or Save dialogue prompt to

1 solution

PDF.js[^]

It's the same PDF viewer that's built in to Firefox.

Quote:
Response.Write(pdfReport.Location + pdfReport.FileName);

That's going to write a string to the response with the path of the report file. That string is not a valid PDF file. You probably meant to use either WriteFile[^] or TransmitFile[^] instead.
 
Share this answer
 
Comments
Shekar Raja 15-May-18 11:32am    
Response.Write(pdfReport.Location + pdfReport.FileName);
the report location is C:\\ drive to bind the .PDF file in IE browser to ask Open or Save dialogue i need to disable prompt to shown PDF file to any configure the PDF viewer dll.
Only IE.
Richard Deeming 15-May-18 11:34am    
If the file exists on the server, then the path to the file on the server will be of no use to the client.

If the file exists on the client, then there is absolutely no way for your code to open it.

In either case, sending a string containing the file path along with a content type of "application/pdf" is the wrong thing to do, and will not work. Your response needs to contain the actual content of the PDF file.
Shekar Raja 15-May-18 11:39am    
PDF embed not working in IE Displaying PDF that are stored outside the Website Root Folder
Richard Deeming 15-May-18 11:42am    
You need two things:

1) A generic HTTP handler to transmit the PDF file from the client to the server; and
2) The viewer included in the PDF.js library, which will let you display that PDF file.

If you change your code to use WriteFile (or TransmitFile), that covers point 1.

And I've already given you the link to PDF.js, which covers point 2.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900