In one of my webpart I have a feature to generate a file dynamically depending on what the users choosed in the view.
On my OnClick event handler, I have this code :
protected void reportClick(object sender, EventArgs e)
{
MemoryStream ms = GenerateFile();
ms.Seek(0, SeekOrigin.Begin);
byte[] byteArray = ms.ToArray();
ms.Flush();
ms.Close();
Context.Response.Clear();
Context.Response.AddHeader("Content-Disposition", "attachment; filename=report.docx");
Context.Response.AddHeader("Content-Length", byteArray.Length.ToString());
Context.Response.ContentType = "application/octet-stream";
Context.Response.BinaryWrite(byteArray);
Context.Response.End();
}
It works as the file is proposed to download to the user. The problem is that after the download, the page is blocked: the buttons are still clickable but there are no actions done on the click. I have to refresh the page to enable the actions again.
Is there a way to download a file without blocking the page ?