Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Response.ContentType = "Application/whoispp-response" 
            Response.AddHeader("Content-disposition", "inline;filename=Reportname.pdf")

 Response.BinaryWrite(bytes)
            Response.Flush()



It is open pdf in acrobat without asking open dialog box,
but one problem arise ,that is the viewer page is shown as empty , I want to show another page , how it is possible?
Posted
Updated 28-Sep-10 20:01pm
v2

Try Response.TransmitFile() to explicitly send the file from your ASP.NET application. This will cause a Open / Save As dialog box to pop up with the filename.

Visit this [Downloading a File with a Save As Dialog in ASP.NET] for more info.
 
Share this answer
 
did you tried window.open() method...
 
Share this answer
 
Comments
sankar guru 29-Sep-10 4:52am    
window.open() menthod need path for the file , but i didnt strore anywhere it.then , can u tell me , how to download pdf file without ask save dialog box ?
If you want to open pdf File in new Tab with clicking hyperlink follow this
1: Add one form as PDFViewer.aspx.
2: on the Page_Load event of this form add following code.

C#
protected void Page_Load(object sender, EventArgs e)
   {
       if (!IsPostBack)
       {
           Response.ClearHeaders();
           Response.ClearContent();
           Response.Redirect("nameofPDFFile.pdf");
       }
   }


3. set properties of hyperlink is follows:
XML
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/PDFViewer.aspx"
            Target="_blank">HyperLink</asp:HyperLink>
 
Share this answer
 
Hi,

Try this,

Using System.Net.WebClient

It Will Show Particular Page with the Content Of Pdf File
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
      string path = Server.MapPath("Doc\demo.pdf");
      WebClient client = new WebClient();
      Byte[] buffer = client.DownloadData(path);


      if (buffer != null)
      {
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-length", buffer.Length.ToString());
        Response.BinaryWrite(buffer);
      }
     }
}


Thanks

Siva Rm K
 
Share this answer
 
v2

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