function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
uptime_andrewuptime_andrew 

Visualforce - Setting Content-Disposition in headers?

I know we can set the content-type header in visualforce using the contenttype attribute for <apex:page>, but can we set Content-Disposition?  E.g.

 

Content-Disposition:attachment;filename=myfile.xls

 

 

metaforcemetaforce

Were you able to figure it out?

ram4SFDCram4SFDC

You can set that in constructor of the visualforce controller

 

Apexpages.currentPage().getHeaders().put('content-disposition', 'attachemnt; filename=mypdf.pdf');

or

Apexpages.currentPage().getHeaders().put('content-disposition', 'attachemnt; filename=\"'+filename+'\"');