?
Solved

Opening a PDF in ASP.net site deployed to server

Posted on 2013-07-02
7
Medium Priority
?
1,033 Views
Last Modified: 2013-07-03
Hi, I have an asp.net 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"
        Response.Clear()
        Response.TransmitFile(path2)
        Response.End()

Thanks
0
Comment
Question by:BWA IT
[X]
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
7 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 2000 total points
ID: 39292601
u can try this:
Response.Write("<script>");
Response.Write("window.open('" + path2 + "', '_newtab');");
Response.Write("</script>");

Open in new window


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

Open in new window

0
 

Author Comment

by:BWA IT
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?

Thanks
0
 
LVL 42

Expert Comment

by:sedgwick
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.
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

Author Comment

by:BWA IT
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?
0
 
LVL 42

Expert Comment

by:sedgwick
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 http://www.mywebsite.com/index.html
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.
0
 

Author Comment

by:BWA IT
ID: 39293486
Thanks worked great!
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39295844
u welcome, good luck.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

719 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