Opening a PDF in site deployed to server

Posted on 2013-07-02
Last Modified: 2013-07-03
Hi, I have an that creates a pdf file and saves it to the c drive. Once it has been saved I would like the pdf document top open for the user. When creating the site in visual studio i used 'System.Diagnostics.Process.Start(path2)' which worked perfectly.

Now I have deployed to a serer and Process.Start doesnt work. I think it may be something to do with permissions but i'm not sure where to look. Could somebody advise?

Alternatively I have tried the code below, this works great but it opens the document in the current window. Is there a method of opening the docuemnt in a new browser window?:

 Response.ContentType = "application/pdf"

Question by:BWA IT
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 42

Accepted Solution

sedgwick earned 500 total points
ID: 39292601
u can try this:
Response.Write("'" + path2 + "', '_newtab');");

Open in new window

or try this with Process.Start:
Process process = new Process();
process.StartInfo.UseShellExecute = true;
process.StartInfo.FileName = path2;

Open in new window


Author Comment

ID: 39292726
I tried the Process.Start method but I get the same problem, the pdf is created but doesnt open.

I tried the Response.Write method but get the error message "Microsoft JScript runtime error: Access is denied." Do you know what that could be?

LVL 42

Expert Comment

ID: 39292733
cam u make sure the path to the pdf file is correct?
it should be url to the pdf location not physical path of the file.
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now


Author Comment

ID: 39292875
Thanks at the moment the pdf is saved to the c drive (using Console.WriteLine) so variable path2 = "C:/newpdf.pdf". How would I change this to a url?
LVL 42

Expert Comment

ID: 39292919
the pdf should be under the directory where your web site is mapped to.
for example when you navigate to the web site, you use
in the background its mapped to the physical directory in the server where index.html resides.
so what u want to do is place the pdf file somewhere under the web site physical path and then u can pass the url relative to the pdf file location.

Author Comment

ID: 39293486
Thanks worked great!
LVL 42

Expert Comment

ID: 39295844
u welcome, good luck.

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question