Postback problem downloading zip file

Posted by Chris Conway on Stack Overflow See other posts from Stack Overflow or by Chris Conway
Published on 2009-01-15T01:12:34Z Indexed on 2010/03/18 1:41 UTC
Read the original article Hit count: 300

Filed under:
|
|
|

I've got a problem on a webforms application where a user selects some criteria from dropdowns 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 app using c# 3.5 for what it's worth.

Thanks!

© Stack Overflow or respective owner

Related posts about postback

Related posts about webforms