0

I have a problem, I have a web application (ASP.NET) it is installed in the server computer, if I run it on my computer (locally) of course it works properly, the reports are generated in my machine.

But when I installed it in the server and access the application from the server, and tried to generate report (using a button) it was not on my machine but it saves to the server machine.

I'm currently using this path as my file saving location:
This is where my Reports(.pdf) saves/generated

string folderDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

What should I do to save my report in my local machine if the web application is installed only in the server?

Btw. im using "iTextSharp" as my PDF Exporter/Generator and System.IO for file handling.

Thanks in advance have a nice day!

Pokechu22
  • 4,984
  • 9
  • 37
  • 62

2 Answers2

0

you have to download this PDF file. 1. use a link 2. or your server code will return you a file result directly.

Liang Lan
  • 100
  • 5
  • Is there a way to show the user's a "Save as" dialog box or download it directly to where he/she wants to save the file ? or even if I do this, will it still save in the server machine? – Curious_Asker Nov 14 '14 at 04:19
0

It should be obvious that you shouldn't save the document as a file on the server, because the more users create a PDF, the more disk space you'll need (or you'll need to clean up the files after they have been server).

It is much better to create the PDF in a memory stream and then serve that stream to the browser. See How to return PDF to browser in MVC? for an example.

If you want the user to see a "Save as" dialog box, you need to define an extra HTTP header:

Response.AppendHeader("content-disposition", "attachment; filename=yourfile.pdf");

Note the value attachment. By default, this value is inline in which case the PDF is shown in the browser. By changing this to attachment, the browser will open a "Save as" dialog box.

Community
  • 1
  • 1
Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165