[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 835
  • Last Modified:

open a pdf file on page load VB 2005

I am trying to open a pdf file when a page is loaded. The following code works in debug mode but not when the page is on line
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
               System.Process.Start("C:\Inetpub\wwwsttest\Documents\Schedule\Manna Summer schedule.htm")
    End Sub
0
whiwex
Asked:
whiwex
  • 4
  • 4
  • 2
1 Solution
 
jpaulinoCommented:
This code opens a pdf ???

Is the pdf already in "Manna Summer schedule.htm" ?
0
 
microboltCommented:
Im assuming you mean it works in Debug mode when its on your local machine in Visual Studio.  And assuming that your uploading your page to a server and its not working.  If thats the case, what you are doing is starting a process on the server everytime you goto the page.  That code will never lauch anything on the client side for security reasons.  If that was possible people could do System.Process.Start("delete *.*") and that would be a bad thing =D

If you want to load a PDF for the end user use Responce.Redirect and navigate them to the PDF page and let thier browser deal with loading the PDF or allowing the user to save it.
0
 
whiwexAuthor Commented:
I'm sorry when the pdf didn't work I tried the htm. The file is in C:\Inetpub\wwwsttest\Documents\Schedule and is called Manna Summer schedule.pdf
So the code is
System.Process.Start("C:\Inetpub\wwwsttest\Documents\Schedule\Manna Summer schedule.pdf")
It will open when I run debug but not on line
Thanks
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
jpaulinoCommented:
have you used Response.Redirect ("")
0
 
whiwexAuthor Commented:
I placed this in the page load but I get Internet explorer can't display the web page
Response.Redirect("http://C:\Inetpub\wwwstalsmanna\Documents\Schedule\Manna Summer Schedule.htm")
0
 
jpaulinoCommented:
But your document should be on
  Response.Redirect("~/Documents/Schedule/Manna Summer Schedule.htm")
not on your computer ...

Have you upload this file ?

0
 
whiwexAuthor Commented:
I tried that samething
0
 
microboltCommented:
How did you upload the files on the webserver?  Depending on how you uploaded it you will need to do:

Response.Redirect("/path/to/Manna Summer schedule.pdf")

and make sure that the PDF is infact uploaded to the server if that doesn't work =D
0
 
whiwexAuthor Commented:
Thanks this worked
Response.Redirect("~\Documents\Schedule\Manna Summer Schedule.htm")
0
 
jpaulinoCommented:
Good work!
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now