View Pdf on browser using asp.net

  Uncategorized

Step 1:  Add the below namespave on the top of the code behind of web page

using System.Net;

Step 2 : You can call the below method to View Pdf on browser using asp.net:-

 public void viewebook(string pdf_filepath)
{
    string FilePath = Server.MapPath(pdf_filepath);
    WebClient User = new WebClient();
    Byte[] FileBuffer = User.DownloadData(FilePath);
    if (FileBuffer != null)
    {
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-length", FileBuffer.Length.ToString());
        Response.BinaryWrite(FileBuffer);
    }

}

 

460 thoughts on - View Pdf on browser using asp.net

LEAVE A COMMENT