Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening remote binary document

Status
Not open for further replies.

tjw2006

Programmer
Nov 16, 2006
103
GB
I've managed to get ASP.NET to open a local pdf document directly to the browser using the code below. However, I'm trying to do the same thing with a pdf document on my local file system (i.e. C:\test\acrobat.pdf), but I keep getting an error saying that the file does not exist. ASP.NET, IIS and my own login have full permissions to this directory, but when I assign "C:\test\acrobat.pdf" to the 'FilePath' variable, I'm getting the error that the file does not exist. Has anyone got any experience of doing this?

Thanks

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Get the physical path to the file.
Dim FilePath As String = MapPath("acrobat.pdf")

'Set the appropriate ContentType.
Response.ContentType = "Application/pdf"

'Write the file directly to the HTTP content output stream.
Response.WriteFile(FilePath)
Response.[End]()
End Sub
 
correct. the server cannot access the client machine. Ideally you do not want the web application reaching out to other points on the network.

if you want to open a pdf document on the client machine you need have the user upload the file to the server.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top