Categories c# response

Specifying filename for dynamic PDF in

How can I specify the filename when dumping data into the response stream?

Right now I’m doing the following:

byte[] data= GetFoo();
Response.Buffer = true;
Response.ContentType = "application/pdf";

With the code above, I get “foo.aspx.pdf” as the filename to save. I seem to remember being able to add a header to the response to specify the filename to save.

Add a content-disposition to the header:

Response.AddHeader("content-disposition", @"attachment;filename=""MyFile.pdf""");