我在按钮点击时生成excel文件下载。下载excel后,响应将停止并结束。您能否建议我如何阻止停止,以便用户可以在不刷新页面的情况下多次下载?
Response.Clear();
Response.ContentType =
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader
(
"content-disposition",
"attachment; filename=PFMWarehouseList_"
+ DateTime.Today.ToString("dd/MM/yyyy") + ".xlsx"
);
Response.BinaryWrite(pck.GetAsByteArray());
//HttpContext.Current.ApplicationInstance.CompleteRequest();
Response.End();
答案 0 :(得分:0)
string Url = "FullPatchYourFile";
FileInfo file = new FileInfo(Url);
try
{
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment;filename=YourFileName");
Response.AddHeader("Content-Type", "application/zip");
Response.ContentType = ".zip"; //YourExtensionFile
Response.AddHeader("Content-Length", file.Length.ToString());
Response.WriteFile(file.FullName);
Response.TransmitFile(file.FullName);
Response.End();
}
finally
{
Your instructions after response.end();
}