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!
you have to download this PDF file. 1. use a link 2. or your server code will return you a file result directly.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.