Asp.net mvc 使用rdlc在asp.net mvc中不显示报告

Asp.net mvc 使用rdlc在asp.net mvc中不显示报告,asp.net-mvc,Asp.net Mvc,我正在尝试使用以下代码显示报告,不幸的是,没有显示或下载 public ActionResult DetailsReport() { LocalReport localReport = new LocalReport(); localReport.ReportPath = Server.MapPath("~/Content/Reports/Data.rdlc"); ReportDataSource repo

我正在尝试使用以下代码显示报告,不幸的是,没有显示或下载

public ActionResult DetailsReport()
        {

            LocalReport localReport = new LocalReport();
            localReport.ReportPath = Server.MapPath("~/Content/Reports/Data.rdlc");
            ReportDataSource reportDataSource = new ReportDataSource("dsData", GetAllData());

            localReport.DataSources.Add(reportDataSource);
            string reportType = "PDF";
            string mimeType;
            string encoding;
            string fileNameExtension;

            //The DeviceInfo settings should be changed based on the reportType
            string deviceInfo =
            "<DeviceInfo>" +
            "  <OutputFormat>PDF</OutputFormat>" +
            "  <PageWidth>8.5in</PageWidth>" +
            "  <PageHeight>11in</PageHeight>" +
            "  <MarginTop>0.5in</MarginTop>" +
            "  <MarginLeft>1in</MarginLeft>" +
            "  <MarginRight>1in</MarginRight>" +
            "  <MarginBottom>0.5in</MarginBottom>" +
            "</DeviceInfo>";

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

            //Render the report
            renderedBytes = localReport.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);
            Response.AddHeader("content-disposition", "attachment; filename=Data." + fileNameExtension);
            return File(renderedBytes, mimeType);


        }

 public static List<vwDataReport> GetAllData()
        {
            var entities = new DataEntities();
            var x = from c in entities.vwDataReport
                    select c;
            return x.ToList();
        }
public ActionResult DetailsReport()
{
LocalReport LocalReport=新建LocalReport();
localReport.ReportPath=Server.MapPath(“~/Content/Reports/Data.rdlc”);
ReportDataSource ReportDataSource=新的ReportDataSource(“dsData”,GetAllData());
localReport.DataSources.Add(reportDataSource);
string reportType=“PDF”;
字符串模拟类型;
字符串编码;
字符串文件名扩展名;
//应根据报告类型更改DeviceInfo设置
字符串设备信息=
"" +
“PDF”+
“8.5英寸”+
“11英寸”+
“0.5英寸”+
“1英寸”+
“1英寸”+
“0.5英寸”+
"";
警告[]警告;
字符串[]流;
字节[]渲染字节;
//提交报告
renderedBytes=localReport.Render(
报告类型,
deviceInfo,
输出mimeType,
输出编码,
输出文件名扩展名,
流出的溪流,
发出警告);
AddHeader(“内容处置”、“附件;文件名=数据”+“文件名扩展名”);
返回文件(renderdbytes,mimeType);
}
公共静态列表GetAllData()
{
var entities=新数据实体();
var x=来自entities.vwDataReport中的c
选择c;
返回x.ToList();
}

只需注释以下行,然后重新构建项目

Response.AddHeader("content-disposition", "attachment; filename=Data." + fileNameExtension);