在前些日子堆棧溢出的一些很好的幫助之後,我放了一個下載腳本。不過,我現在已經發現,在文件下載後,我需要重新加載頁面以擺脫aspx頁面上的進度模板。在添加到下載代碼之前,刪除模板的代碼已經工作。文件下載後的更新頁面
代碼刪除進度模板:upFinanceMasterScreen.Update();
我已經打過電話把這個前後重定向到IHttpHandler
Response.Redirect("Download.ashx?ReportName=" + "RequestingTPNLeagueTable.pdf");
public class Download : IHttpHandler {
public void ProcessRequest(HttpContext context)
{
StringBuilder sbSavePath = new StringBuilder();
sbSavePath.Append(DateTime.Now.Day);
sbSavePath.Append("-");
sbSavePath.Append(DateTime.Now.Month);
sbSavePath.Append("-");
sbSavePath.Append(DateTime.Now.Year);
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ContentType = "application/pdf";
HttpResponse objResponce = context.Response;
String test = HttpContext.Current.Request.QueryString["ReportName"];
HttpContext.Current.Response.AppendHeader("content-disposition", "attachment; filename=" + test);
objResponce.WriteFile(context.Server.MapPath(@"Reports\" + sbSavePath + @"\" + test));
}
public bool IsReusable { get { return true; } }
感謝您的幫助,您可以提供!
謝謝!我不認爲這是可能的,但只是想我會問。 – flyersun 2010-10-27 09:05:15
由於您不能在同一頁面上顯示兩個頁面,爲什麼不使用兩個頁面呢!我的方法是更新並彈出另一個頁面(使用JavaScript windows.open())來處理下載。你可能希望看看'Page.ClientScript.RegisterStartupScript'。希望這有助於他人。 – user3454439 2017-01-05 06:42:39