Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
How to open a pdf file in Asp.net like in web site
Open E-Book Like in open as Google book
Posted 14-Dec-12 3:12am
Edited 14-Dec-12 3:28am
v2
Comments
aspnet_regiis -i at 14-Dec-12 8:20am
   
what ?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
Have a look at this question:
http://forums.asp.net/t/1219837.aspx[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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();
                    }
                }
  Permalink  
v2

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



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 14 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100