Giri
Giri

Reputation: 941

how to show dialog box before downloading the dynamically generated pdf?

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.

Upvotes: 0

Views: 1869

Answers (3)

Giri
Giri

Reputation: 941

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.

Upvotes: 1

nunespascal
nunespascal

Reputation: 17724

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();  

Upvotes: 1

Alberto León
Alberto León

Reputation: 2921

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

Upvotes: 0

Related Questions