Click here to Skip to main content
15,662,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hii,

i am stuck in pdf view on browser while giving the path of physical server

What I have tried:

my code is

<pre>string FilePath = "~/pdfs/channel-hw list.pdf";

string embed = "<object data=\"{0}\" type=\"application/pdf\" width=\"900px\" height=\"600px\">";
        ltEmbed.Text = string.Format(embed, ResolveClientUrl(FilePath));


i want to put filepath as physical server address(e.g. \\servername\foldername\filename.pdf). but it not showing any result
Posted
Updated 31-Oct-17 17:10pm
v4

1 solution

try using Server.MapPath Method[^]
string folder = Server.MapPath("pdfs");
           string filePath = System.IO.Path.Combine(folder, "channel-hw list.pdf");
           string embed = "<object data=\"{0}\" type=\"application/pdf\" width=\"900px\" height=\"600px\">";
           ltEmbed.Text = string.Format(embed,   filePath);
 
Share this answer
 
Comments
sushant09 1-Nov-17 1:46am    
still not getting result.

Server.MapPath("pdfs")
this method redirecting to the solution folder of visual studio. but my pdf file is in the remote server .how can i redirect on remote server
Karthik_Mahalingam 1-Nov-17 2:01am    
try giving the entire path and check
sushant09 1-Nov-17 2:23am    
i used following code

string folder = Server.MapPath(@"\\servername\test\");
string filePath = System.IO.Path.Combine(folder, "testfile.pdf");
string embed = "<object data=\"{0}\" type=\"application/pdf\" width=\"900px\" height=\"600px\">";
ltEmbed.Text = string.Format(embed, filePath);

i can able to dowload the file from remote server(using same path) but at same time i cant view the file on browser.
Karthik_Mahalingam 1-Nov-17 2:44am    
you cannot give the location other than hosted directory to the object directly..
place the files in the project folder and try.
sushant09 2-Nov-17 0:59am    
is there any solution to do this?
because i want to display pdf from remote server.

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