User-939850651 posted
Hi Edward Sheriff Curtis,
With this code my problem is after downloading the excel file from the page xls.aspx my loading screen it does not close and remains fixed on the browser...
You seem to want the page to automatically close the page after the download file response is complete?
If this is the case, I think you can try it like this:
Response.ContentType = "xxx/xxx";
Response.AppendHeader("Content-Disposition", "attachment; filename=xxx.xxx");
Response.TransmitFile(filePath);
Response.End();
System.Threading.Thread.Sleep(2000);
//ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "window.close();", true);
Response.Write("<script language=javascript>this.window.opener = null;window.open('','_self'); window.close(); </script>");
But in chrome browser, you can't close the page by script, you can only do it manually.
The code works on IE and Edge, or you can choose to return to the previous page after the download is complete.
Best regards,
Xudong Peng