[英]Unable to render excel download from aspx page
我有一個ASP.NET(網絡表單)頁面,單擊按鈕即可將MS-Excel呈現回響應流。 一切都可以在測試中正常運行,但是在實時部署中,瀏覽器似乎正在嘗試下載文件后,出現了這個對話框: 其中ReportsShow.aspx是生成並呈現Excel的aspx頁面的名稱。 觸發下載的按鈕會觸發回發,因此我迷惑為什么為什么在正確加載時找不到頁面? 我一無所知,任何幫助將不勝感激
編輯 :根據Mayank的要求,這是代碼結構:
// Get instance of reporting service
IReportingService reportingServiceClient = Reports.GetWebService();
// Get a fresh copy of the report
BusinessReport theReport = reportingServiceClient.GetReport(AcctList.ToArray());
ExcelExport excelExport = new ExcelExport();
const string templateFileName = "Business-Report.xls";
string newFileName = String.Empty;
try
{
newFileName = excelExport.CopyTemplateFile(Server.MapPath("~/ExportTemplates/" + templateFileName));
excelExport.WriteData(forexOptionReport, newFileName);
Response.Clear();
Response.AddHeader("content-disposition", string.Format("Attachment; filename=\"{0}\"", "Business-Report" + ".xls"));
Response.ContentType = "application/vnd.ms-excel";
Response.TransmitFile(newFileName);
Response.Flush();
}
catch (Exception ex)
{
Errors.LogException("Error in Reports.BtnDownloadToExcel_Click", ex);
throw;
}
finally
{
if (!String.IsNullOrEmpty(newFileName))
{
excelExport.DeleteFile(newFileName);
}
}
更多信息
我已經用提琴手對此進行了分析,這是我對特定請求/響應所看到的,該請求/響應有望提供可下載的excel:
此Stackoverflow Q / A指出,禁止圖標的含義是客戶端正在終止/中止響應
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.