Click here to Skip to main content
15,909,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to open a pdf file in Asp.net like in web site
Open E-Book Like in open as Google book
Posted
Updated 14-Dec-12 2:28am
v2
Comments
bbirajdar 14-Dec-12 8:20am    
what ?

Hi,

Have a look at this question:
http://forums.asp.net/t/1219837.aspx[^]
 
Share this answer
 
C#
DataSet ds = new DataSet();
                ds = GetFile();

                if (ds.Tables[0].Rows.Count == 1)
                {
                    string strContentType = ds.Tables[0].Rows[0]["FileType"].ToString();
                    Response.Charset = "";
                    Response.ContentType = strContentType;
                    Response.AppendHeader("Content-Type", strContentType);
                    int nlen = Int32.Parse(ds.Tables[0].Rows[0]["FileSize"].ToString());

                    if (nlen > 0)
                    {
                        byte[] myData = new byte[nlen];
                        myData = (byte[])ds.Tables[0].Rows[0]["CompanyBrochure"];
                        MemoryStream mstream = new MemoryStream(myData, 0, myData.Length);
                        Response.Clear();
                        Response.Buffer = true;
                        //string fileName = Path.GetFileName(ds.Tables[0].Rows[0]["FileType"].ToString());
                        string fileName = "";
                        Response.AddHeader("Content-Disposition", "inline;filename=" + fileName);
                        Response.BinaryWrite(mstream.ToArray());
                        Response.Flush();
                        Response.End();
                    }
                }
 
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