I’ve got a problem on a WebForms application where a user selects some criteria from drop downs on the page and hits a button on the page which calls this method:
protected void btnSearch_Click(object sender, EventArgs e)
They then click on button to download a zip file based on the criteria which calls this method:
protected void btnDownload_Click(object sender, EventArgs e)
In IE, they are prompted with the bar at the top of the browser that tells them:
“To help protect your security, Internet Explorer blocked this site
from downloading files to your computer”.
When they click on that bar to download the file, it fires the btnSearch_Click event again.
Response.ContentType and Response.AddHeader has been set up correctly.
The problem is, that btnSearch appends criteria so basically it is being appended twice and causing problems.
Is there something I can do to prevent this?
This is a VS2008 web application using C# 3.5 for what it’s worth.
When they click the download button, do a Redirect to the ZIP file handler (page?) to download the file. i.e. use the Post-Redirect-Get pattern: http://en.wikipedia.org/wiki/Post/Redirect/Get