How to render RDLC to PDF in IE and Opera

空扰寡人 提交于 2019-12-11 17:51:01

问题


My question seems a duplicate question but I have an strange issue here. We have a web application that render RDLC reports to PDF format that has some parameter that will be set in code then append to the report and render it to PDF. I have this code behind:

LocalReport rep = new LocalReport();
        rep.ReportPath = "ReimbursementClaimForm.rdlc";
        List<ReportParameter> param = new List<ReportParameter>();
        param.Add(new ReportParameter("NameofthePatient", txtNameofthePatient.Text));
        param.Add(new ReportParameter("MBASIDNo", txtMBASIDNo.Text));
        param.Add(new ReportParameter("DateofBirth", string.Format("{0:dd MMMM, yyyy}", Convert.ToDateTime(txtDateofBirth.Text))));
        param.Add(new ReportParameter("CompleteHomeAddress", txtCompleteHomeAddress.Text));
        param.Add(new ReportParameter("EmailAddress", txtEmailAddress.Text));
        param.Add(new ReportParameter("ContactNos", txtContactNos.Text));
        param.Add(new ReportParameter("ExpenseClaim", txtExpenseClaim.Text));
        param.Add(new ReportParameter("AccountHolderName", txtAccountHolderName.Text));
        param.Add(new ReportParameter("AccountHolderName2", txtAccountHolderName2.Text));
        param.Add(new ReportParameter("AccountNoandAccountType", txtAccountNoandAccountType.Text));
        param.Add(new ReportParameter("BankName", txtBankName.Text));
        param.Add(new ReportParameter("BankBranch", txtBankBranch.Text));
        param.Add(new ReportParameter("BankContactNo", txtBankContactNo.Text));
        param.Add(new ReportParameter("BankAddress", txtBankAddress.Text));
        param.Add(new ReportParameter("BICSwiftCode", txtBICSwiftCode.Text));
        param.Add(new ReportParameter("RTGSCode", txtRTGSCode.Text));
        param.Add(new ReportParameter("IBAN", txtIBAN.Text));
rep.SetParameters(param);
        rep.DisplayName = "ReimbursementClaimForm";
        rep.Refresh();
HttpContext.Current.Response.Buffer = true;
        //HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.AppendHeader("content-disposition", "attachement filename=" + Rep.DisplayName + ".pdf");
        HttpContext.Current.Response.ContentType = "application/PDF";
Warning[] warnings;
            string[] streamids;
            string mimeType;
            string encoding;
            string extension;
            byte[] bytes = item.Render("Pdf", null, out mimeType, out encoding, out extension, out streamids, out warnings);
        HttpContext.Current.Response.BinaryWrite(bytes);
        HttpContext.Current.Response.Flush();
        HttpContext.Current.Response.End();

The problem here is that whenever I deploy the app using this code values on the ReportParameter that are set from the values of textboxes on ASP are not reflected in the generated PDF file. At first try values rendered but on the second time around values not updated on the PDF. This happens on IE and Opera browsers but on other browsers its fine and take note once the web app was deployed on IIS but on my local machine it works fine in all browsers. Thanks in advance.


回答1:


Most probably caching issues. Add this line to just over your Response.Clear()

HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);

Clear your browser cache and try again



来源:https://stackoverflow.com/questions/16641904/how-to-render-rdlc-to-pdf-in-ie-and-opera

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!