Click here to Skip to main content
15,909,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi good morning

Actually I am not able to view the PDFs or word file on asp.net web-form.

First I am uploading the file on server.

Second I will see all the file names in grid-view and when I select the particular file than that file should be open in new web-form.

So please help me out to solve this problem.
Posted

Hi using two way u can show pdf on web Form

1)
using System.Net;

string pdfPath = Server.MapPath("~/SomePDFFile.pdf");
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(pdfPath);
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", buffer.Length.ToString());
Response.BinaryWrite(buffer);

2)
Response.Redirect("~/somePDFFile.pdf");

Best Luck
happy Coding
 
Share this answer
 

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