Hi I'm stuck in the next situation, I need to open a pdf file which I uploaded to sever first. I've tried the following code:
string Servidor = Request.Url.GetLeftPart(UriPartial.Authority);
var fullUrl = Servidor + Session["strUrl"];
var NewProcess = new System.Diagnostics.Process();
NewProcess.StartInfo.FileName = fullUrl;
NewProcess.Start();
This code works fine when I'm in localhost, but when I deploy my web application, it doesn't work. Is there any other solution to accomplish this?
In your generated html you need a "target" attribute on the "a" tag with a window name, or more generically "_blank" to open a new window
eg
<a href="document.pdf" target="_blank">Open document in a new window</a>
or in pure asp.net
<asp:HyperLink id="hyperlink1" NavigateUrl="document.pdf" Target="_blank" Text="Open document in a new window" runat="server"/>
You can't open a PDF by starting a new process on a remote server. You have to create a link on a webpage thats hosted on the server which points to the pdf you want to open (which also should be hosted on the web server).
<a href="file.pdf">Open</a>
Use this code. This works like a champ.
Process process = new Process();
process.StartInfo.UseShellExecute = true;
process.StartInfo.FileName = outputPdfFile;
process.Start();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.