We help IT Professionals succeed at work.

Open a PDF file with VB.NET

the code below work fine while in the devloping environment but does nothing when the page is published and does not raise any errors any clue why?
the web server is 2003 server with IIS set up to emulate .net framework 2
 
   Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
        Dim filename As String
        Dim path As String
        filename = "f:\webso\invoices\" + Trim(GridView1.SelectedRow.Cells(0).Text) + ".pdf"
        path = Page.ResolveClientUrl(filename)
        System.Diagnostics.Process.Start(path)
    End Sub
Comment
Watch Question

Project manager
CERTIFIED EXPERT
Commented:
Does your web-application have the rights for the f-drive.
Can you add a error-handler, perhaps we see an error
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
try
        Dim filename As String
        Dim path As String
        filename = "f:\webso\invoices\" + Trim(GridView1.SelectedRow.Cells(0).Text) + ".pdf"
        path = Page.ResolveClientUrl(filename)
        System.Diagnostics.Process.Start(path)
catch ex as exception
   messagebox.show ex.tostring
end try
    End Sub

Open in new window

Commented:
It's more likely that you really intended to send the pdf to the client PC to be rendered by the client's browser (rather than render it on the Web server via a Process.Start)

Author

Commented:
can you send me a code snippet for that or point me in the right direcion.
where can i find a sample code for that

Author

Commented:
Dhaest
thanks for the reply
there is an F drive and the files are there i don't get any errors from the browser it just show done on the bottom left side of the page but nothing is open.
i tried as a test to remove the files to see if an error will be triggered and it did so the files are in the right place.
Dirk HaestProject manager
CERTIFIED EXPERT

Commented:
Do you have a popup-blocker installed ?
Do you have a pdf-reader installed ?

Author

Commented:
no popup blocker
yes PDF reader installed
Dirk HaestProject manager
CERTIFIED EXPERT

Commented:
Can you give this a try
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
        Dim filename As String
        Dim path As String
        filename = "f:\webso\invoices\" + Trim(GridView1.SelectedRow.Cells(0).Text) + ".pdf"
        path = Page.ResolveClientUrl(filename)
        response.redirect(path)
    End Sub

Open in new window

Commented:
I keep wondering if the Author had intended to render the PDF on the server... or send it to the client to be rendered in the browser

Author

Commented:
at this point i don't care i would rather send to client to be open on his browser

Explore More ContentExplore courses, solutions, and other research materials related to this topic.