Cosmin Spirescu wrote:
Hi,
It should be something very simple, but I do not know what I do wrong.
I display some PDF filenames form a folder into a gridview and when the user
clicks on the name, it execute this code.
System.Diagnostics.Process.Start(filename)
'filename' is the full path of the file (like 'C:\Folder\file.pdf')
When I run this from VS ( on http://localhost: ...) it runs ok and open the
file in a new windows.
When I pulish the site and run it from the server the PDF doesn't open, and
no error message appear (not even a javascript error).
I do not know why... please help. ;)
Hi Cosmin,
What are you actually trying to achieve? Process.Start is trying to run
the file on the server, not on the machine with the browser window. Is
this really what you're trying to achieve? Usually the best options
when wanting to run things on the server in response to website stuff
are 1) Having a service that can run programs independantly, or 2)
Having a program that runs when a user logs in. In both cases, the
website communicates with this other program using remoting or other
techniques (2 is preferred if interaction with the desktop e.g. a
window) may be required)
If, on the other hand (as I suspect), you're wanting the PDF to open at
the browser end, you're better of either directly linking to the pdf
file, or if (for security checking reasons, or if the files reside
somewhere that you cannot map a virtual directory to, etc), then you'll
probably want to change the Response.ContentType property to the
appropriate type for PDF and then stream the PDF down to the browser
using the Response.OutputStream
Damien