Rdlc使用MVC4无法在IIS7上运行

时间:2014-04-04 08:50:06

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

我是使用Entity Framework的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);

1 个答案:

答案 0 :(得分:0)

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

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

并发布您的网站。

您可以阅读有关发布RDLC Here

的更多信息