1 Replies - 571 Views - Last Post: 28 July 2017 - 05:52 AM Rate Topic: -----

#1 November-06  Icon User is offline

  • D.I.C Regular

Reputation: 53
  • View blog
  • Posts: 482
  • Joined: 04-January 11

Button Firing Multiple Times

Posted 28 July 2017 - 02:38 AM

How can I prevent my button from firing multiple times when using Response.End()?

I am creating folders and files, then compressing them into a zip file then download that zip file.

In the download, I have this code...

HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", filename));
HttpContext.Current.Response.AddHeader("Content-Length", stream.Length.ToString());
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.OutputStream.Write(file, 0, file.Length);
HttpContext.Current.Response.End();



After Response.End(), the button fires again so the steps are re-done causing app to slow down. And it's not just firing twice but multiple times of around 5 or 6. How can this be prevented?

Is This A Good Question/Topic? 0
  • +

Replies To: Button Firing Multiple Times

#2 November-06  Icon User is offline

  • D.I.C Regular

Reputation: 53
  • View blog
  • Posts: 482
  • Joined: 04-January 11

Re: Button Firing Multiple Times

Posted 28 July 2017 - 05:52 AM

Turned out, it wasn't caused by the Response.End(). Instead, a downloader which is a browser extension caused the multiple triggering of the button. I disabled the extension so I do not experience that problem now.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1