【问题标题】:Rdlc using MVC4 not working on IIS7使用 MVC4 的 Rdlc 在 IIS7 上不起作用
【发布时间】:2014-04-12 19:58:32
【问题描述】:

我是使用实体框架的 MVC4 新手。现在我正在做 RDLC 报告,这里我将参数传递给报告以过滤数据。它正在本地工作。当我在服务器上发布时,它不起作用。它显示异常(处理您的请求时发生错误)。我无法找到确切的错误。请帮我解决这个问题。提前致谢。 这是我的控制器代码:

 var name = Convert.ToString(form["name"]);
                var date = Convert.ToString(form["cdate"]);
                var dateList = Convert.ToDateTime(form["cdate"]);
                string id = Convert.ToString(form["value"]);
                //id = "PDF";
                LocalReport lr = new LocalReport();
                string path = Path.Combine(Server.MapPath("../Reports"), "DailyReport.rdlc");
                if (System.IO.File.Exists(path))
                {
                    lr.ReportPath = path;
                }
                else
                {
                    return View("Index");
                }

                //Assigning the parameters to the list
                List<ReportParameter> lst = new List<ReportParameter>();
                ReportParameter rptName = new ReportParameter("rptname", name);
                ReportParameter rptDate = new ReportParameter("rptdate", date);
                lst.Add(rptName);
                lst.Add(rptDate);
                lr.SetParameters(lst);
                var rptData =
                from d in db.Tbl_DailyReport
                where (d.CreatedOn == dateList)
                join u in db.Tbl_Users on d.CreatedBy equals u.UserID
                where (u.UserName == name)
                join c in db.Tbl_Mst_City on u.UserCity equals c.CityId
                join ds in db.Tbl_Mst_Designation on u.UserDesignation equals ds.DesignationID

                select new
                {
                    u.UserName,
                    c.CityName,
                    ds.Designation,
                    d.DailyReport,
                    d.Achivement,
                    d.ReportTime,
                    d.Comment,
                    d.CreatedOn
                };

                //Passing the parameters to the report
                ReportDataSource rd = new ReportDataSource("DataSet_dr", rptData);
                lr.DataSources.Add(rd);
                lr.Refresh();
                string reportType = id;
                string mimeType;
                string encoding;
                string fileNameExtension;
                string deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>" + id + "</OutputFormat>" +
                "  <PageWidth>8.5in</PageWidth>" +
                "  <PageHeight>11in</PageHeight>" +
                "  <MarginTop>0.5in</MarginTop>" +
                "  <MarginLeft>0.5in</MarginLeft>" +
                "  <MarginRight>0.5in</MarginRight>" +
                "  <MarginBottom>0.5in</MarginBottom>" +
                "</DeviceInfo>";

                Warning[] warnings;
                string[] streams;
                byte[] renderedBytes;

                renderedBytes = lr.Render(
                    reportType,
                    deviceInfo,
                    out mimeType,
                    out encoding,
                    out fileNameExtension,
                    out streams,
                    out warnings);

                return File(renderedBytes, mimeType);

【问题讨论】:

    标签: asp.net-mvc-4 entity-framework-4 rdlc


    【解决方案1】:

    不确定您想要什么,但在发布您的网站时尝试如下设置 RDLC 报告的属性。

    构建操作 = 内容, 复制到输出目录 = 如果更新则复制。

    并发布您的网站。

    您可以阅读有关发布 RDLC 的更多信息Here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-25
      • 2012-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多