LaceySnr.com - Salesforce Development Posts by Matt Lacey

Forcing Internet Explorer to Download A Visualforce Page - WTF

Posted: 2011-01-25

Second post in two days – fastest updates ever for this blog. Anyway, sometimes you want to use Visualforce to return a file to a user, be it an excel file or outlook calendar item for example. You've probably gotten as far as specifying the content type in the page tag and then some bright spark has fired up that most cursed of browsers, Internet Explorer. They'll soon be telling you that Internet explorer is refusing to download the file you're creating – the solution to this annoyance (at least it was the solution for us and a few others I've seen online)? Specify cache="true" in the page tag too.

That's it. I have no idea why IE should need this and I'm not about to spend the time looking into it because frankly I like to spend as little time as possible dealing with IE and it's various idiosyncrasies. Just for the sake of an example, here's the full page tag we're now using in our Visualforce page:

<apex:page controller="QVFC_CalandarCreate" action="{!init}" contenttype="text/calendar#Calander.vcs" cache="true">