先日のスタック オーバーフローからのすばらしい助けを借りて、ダウンロード スクリプトをまとめました。ただし、ファイルがダウンロードされた後、ページをリロードして 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; } }
ご協力いただきありがとうございます。