嗨,我被困在下一个情况下,我需要打开一个pdf文件,我首先上传到服务器。我已经尝试了以下代码:
string Servidor = Request.Url.GetLeftPart(UriPartial.Authority);
var fullUrl = Servidor + Session["strUrl"];
var NewProcess = new System.Diagnostics.Process();
NewProcess.StartInfo.FileName = fullUrl;
NewProcess.Start();当我在localhost中时,这段代码工作得很好,但是当我部署我的web应用程序时,它就不能工作了。有没有其他的解决方案来实现这一点?
发布于 2011-08-16 09:28:59
在生成的html中,您需要"a“标记上的"target”属性和窗口名称,或者更通用的"_blank“属性来打开一个新窗口。
例如:
<a href="document.pdf" target="_blank">Open document in a new window</a>或者使用纯asp.net
<asp:HyperLink id="hyperlink1" NavigateUrl="document.pdf" Target="_blank" Text="Open document in a new window" runat="server"/> 发布于 2011-08-16 07:28:35
您无法通过在远程服务器上启动新进程来打开PDF。你必须在一个网页上创建一个链接,该网页托管在服务器上,指向你想要打开的pdf (这也应该在web服务器上托管)。
<a href="file.pdf">Open</a>发布于 2013-02-27 04:36:54
使用此代码。这就像冠军一样工作。
Process process = new Process();
process.StartInfo.UseShellExecute = true;
process.StartInfo.FileName = outputPdfFile;
process.Start();https://stackoverflow.com/questions/7071475
复制相似问题