Search code examples
asp.netupdatepanelfilestreamdownload

Download file from stream using UpdatePanel


We are trying to download file from bytestream like this:

            byte[] arrBytes = x.Result;
            Response.ClearContent();
            Response.ClearHeaders();
            Response.Buffer = true;
            Response.ContentType = file.MimeType;
            Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Title);
            Response.OutputStream.Write(arrBytes, 0, arrBytes.Length);
            Response.Flush();

its working without update panel, but using update panel the same is not getting downloaded. Please suggest some workaround.


Solution

  • Probably you are using <asp:AsyncPostBackTrigger>, please replace it with <asp:PostBackTrigger>