views:

163

answers:

1

I've observed that under certain circumstances, a web browser will navigate to a blank page and then prompt the user to download a file. In my current situation, it's navigating to a URL that generates an Excel file. The download of the file works perfectly, but the user is now stranded on a blank page. There are two things I would like to figure out:

  1. What causes the blank page to be displayed? It doesn't happen all the time. Is it the difference between using GET and POST (I can't recall seeing a hyperlink do it, but forms usually do)? Is it something to do with the Content-Disposition? In my current case, I've set the Content-Disposition to be "inline" because I want it to display in the browser in IE. Firefox (and presumably others) will of course prompt to download because they can't display it inline. It is the situation where the user chooses to save it that the blank screen results.
  2. If it is possible, I'd like to display some content on this blank screen to provide the user with a message like "your file has been generated, click here to go back to the main screen" or somesuch. Is there a way I can do that?

I'm using an IIS extension written in C++, so solutions for ASP, PHP, etc will not be helpful unless they're generally applicable (though I wouldn't mind learning about solutions in those languages!). Thanks.

+1  A: 

I think you practically answered your own question: setting content-disposition to inline does exactly that. One solution that comes to mind is browser detection: use inline disposition if the browser is IE, attachment otherwise.

BTW, as a user, I prefer sites which offer me a choice whether I want to download the file or view it inside the browser (when, for example, accessing a PDF file). In this case, I would consider having a link/button for downloading the file, and adding a second link/button for IE browsers to view it.

David Hanak
oddly, the way I have it set up now prompts the user to open or save in IE, and if they choose open, it opens inline. I had never seen that behavior before, and I don't know if it was caused by something I did... IE7, btw.
rmeador