I have an ASP.NET (webforms) page that renders MS-Excel back to the response stream on click of a button. Everything works perfectly in testing but on live deployment, I get this dialogue box after the browser appears to be trying to download the file:
where ReportsShow.aspx is the name of the aspx page that generates and renders the excel.
The button that triggers the download fires a postback so I am confounded as to why the page would not be found when it renders correctly on load?
I am clueless and any help would be greatly appreciated
EDIT: As requested by Mayank, here's the code structure:
// 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);
}
}
MORE INFO
I've analyzed this with fiddler and this is what I see for the particular request/response which is expected to present the excel for download:
This Stackoverflow Q/A states that the meaning of the forbidden icon is that the client is terminating/aborting the response