C# 在c中从服务器位置打开pdf文件#
我们需要从服务器中的特定位置打开pdf文件,即“C:\PdfFile\Test.pdf” 我尝试过这个解决方案:C# 在c中从服务器位置打开pdf文件#,c#,asp.net,pdf,C#,Asp.net,Pdf,我们需要从服务器中的特定位置打开pdf文件,即“C:\PdfFile\Test.pdf” 我尝试过这个解决方案: string fileName = lnk.CommandArgument.ToString(); System.Diagnostics.ProcessStartInfo a = new System.Diagnostics.ProcessStartInfo(fileName, "Open"); Syste
string fileName = lnk.CommandArgument.ToString();
System.Diagnostics.ProcessStartInfo a = new System.Diagnostics.ProcessStartInfo(fileName, "Open");
System.Diagnostics.Process.Start(a);
这适用于本地,因为我们在本地有相同的路径,但当我们托管站点时,这不起作用。在ASP.NET表单应用程序中,您必须添加以下代码:
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename=MyFile.pdf");
Response.TransmitFile(Server.MapPath(@"C:\PdfFile\Test.pdf"));
Response.End();
好的,在服务器上打开PDF时发生了什么?谁会看它?它在服务器上是打开的,但我需要在本地打开它。但是有代码的应用程序托管在服务器上。。。。一个网站。不是在客户机上。那么,根据您的需求,您希望您的代码有什么意义呢?这就是我需要的。我需要在本地环境而不是服务器中打开pdf文件。