How to download a file from Sitecore Sheer UI Popup

I had this case where you need to download a file from a Sitecore Sheer UI Popup, like a PDF file or Excel Sheet directly from the browser without using the SaveAs dialog. The first thing that comes to your mind is to use the HttpResponse to download the stream file as the following:

You should not be surprised if no matter you tried to do so, the file will not be there!! As the popup will not allow writing the response (the response would be empty and no files are there). What I did to overcome this issue after trying different approaches and solutions is to use an IFrame and call the download code above in the page load. So what happens here is that the download button will read the file and store file information in the session (you can use any format, these used here for more clarification) and build up the IFrame and call the SheerResponse.Eval to call the IFrame page. Once all are downloaded, you can clear the session.

It took time to figure out this solution so I hope it would be helpful🙂

3 thoughts on “How to download a file from Sitecore Sheer UI Popup

  1. Thank you for posting, I found it quite useful but I have to mention that it would have been quite handy if you included the code as text instead of screenshots of code.

  2. Pingback: Re-blogged: How to download a file from Sitecore Sheer UI Popup | Sitecoring

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s