I would like to use standard ASP.NET file download response, like in other Stack Overflow question.
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition","attachment; filename=logfile.txt");
Response.TransmitFile( Server.MapPath("~/logfile.txt") );
Response.End();
But inside update panel it does not work. What I have to do, that I will get a file if the download event is triggered inside update panel?
Well, I have found nice blog post on Encosia which describe solution of this ASP.NET AJAX file download problem. It work really nice.
http://encosia.com/2007/02/23/ajax-file-downloads-and-iframes/
You need to have this in a separate aspx that does not use ajax. Ajax is updating existing html markup on a page at the client side. What you try here is replace the responce content on the server side before sending anything to the client.
You could try this:
Have a page called Download.aspx
that contains the transmit code you already have.
In your original page, you have a javascript call that calls the download page like this:
window.location.replace('Download.aspx');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With