Load PDF on Browser in ASP.NET

  1. using System.Net;  
  2. public void ViewPDF(string path)  
  3. {  
  4.     string FilePath = Server.MapPath(path);  
  5.     WebClient User = new WebClient();  
  6.     Byte[] FileBuffer = User.DownloadData(FilePath);  
  7.     if (FileBuffer != null)  
  8.     {  
  9.         Response.ContentType = "application/pdf";  
  10.         Response.AddHeader("content-length", FileBuffer.Length.ToString());  
  11.         Response.BinaryWrite(FileBuffer);  
  12.     }  
  13.   
  14. }