0

I am using ASP.NET, C# and iTextSharp for creating a PDF. Then I am using this code for transmitting the file.

Response.TransmitFile(filename);

So I want to display a dialog box which will request the user whether to open/save/cancel when they click on the generate button.

Thanks.

Giri
  • 931
  • 11
  • 31
  • 51

3 Answers3

1

You can write it to the response directly. Browser will show the save as/open depending on the type sent.

Response.ContentType = "application/pdf";
Response.WriteFile(@"C:\Downloads\Test.pdf");
Response.Flush();  
nunespascal
  • 17,584
  • 2
  • 43
  • 46
  • Thanks..but what if he don't have that download folder or don't have access to C:\.. – Giri Sep 13 '12 at 06:58
  • That was just a sample path. Give it the path to where ever you generated the file. If you are generating the file in memory, you can write the bytes directly to the `Response.OutputStream` – nunespascal Sep 13 '12 at 07:09
1
Responce.AddHeader("content-disposition","attachement;filename=name.pdf");
Response.TransmitFile(filename);

Here content-disposition is the one which is used for displaying the dialog box.

coolguy
  • 7,866
  • 9
  • 45
  • 71
Giri
  • 931
  • 11
  • 31
  • 51
0

As I remember, is the navigator who decides make the download for load it inside navigator.

Normally the unique way to download it is offer a link and guide the user to right click and to choose Save As

Alberto León
  • 2,879
  • 2
  • 25
  • 24