We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Report loads, but is not displayed

I am able to export and print the report, but I can't view it in the browser. In Chrome and Firefox, I see the toolbar, but nothing underneath it.

First I made an rdl with SQL Server 2016 Report Builder, and wondered if there was some sort of compatibility issue so I made a similar rdlc in VS 2017. Both will print and export properly. In Firefox the rdlc will show a a quarter inch of so of the report AFTER I try to print and cancel the print.


OnInitReportOptions() has been modified from the examples I found with my own datasource and datasourcecredentials. I also set it to a local processing.

My View

<ej-report-viewer id="reportviewer1" report-service-url="/Incidents"></ej-report-viewer>

<script type="text/javascript">
    function onReportPrint(args) {
        args.isStyleLoad = false;
    }
</script>


Controller
   public partial class IncidentsController : Controller, IReportController
    {
        private IMemoryCache _cache;
        private IHostingEnvironment _hostingEnvironment;

        public IncidentsController(IMemoryCache memoryCache, IHostingEnvironment hostingEnvironment)
        {
            _cache = memoryCache;
            _hostingEnvironment = hostingEnvironment;
        }

        public ActionResult Index()
        {
         
            return View();
        }

        public IActionResult Error()
        {
            return View();
        }


        [HttpPost]
        public object PostReportAction([FromBody] Dictionary<string, object> jsonResult)
        {
            if (jsonResult.ContainsKey("CustomData"))
            {
                var paramValue = jsonResult["CustomData"];
            }
            return ReportHelper.ProcessReport(jsonResult, this, this._cache);
        }

        [ActionName("GetResource")]
        [AcceptVerbs("GET")]
        public object GetResource(ReportResource resource)
        {
            return ReportHelper.GetResource(resource, this, _cache);
        }

        [HttpPost]
        public object PostFormReportAction()
        {
            return ReportHelper.ProcessReport(null, this, this._cache);
        }

        public void OnInitReportOptions(ReportViewerOptions reportOption)
        {
            string basePath = _hostingEnvironment.WebRootPath;
            FileStream inputStream = new FileStream(basePath + @"\Incidents.rdlc", FileMode.Open, FileAccess.Read);
            reportOption.ReportModel.Stream = inputStream;
            //DataSet ds = new DataSet();
            //ds = Loadds();
            OdbcConnection connection = new OdbcConnection("Driver={ODBC Driver 17 for SQL Server}; Server=localhost\\SQLEXPRESS;Database=GirlsHaven;Trusted_Connection=Yes;MultipleActiveResultSets=true;ColumnEncryption=Enabled;App=dataset;");
            var strsql = "SELECT * from qryIncidents";
            OdbcDataAdapter adapter = new OdbcDataAdapter(strsql, connection);

            DataSet ds = new DataSet();
            adapter.Fill(ds);
            reportOption.ReportModel.DataSources.Clear();
            reportOption.ReportModel.DataSources.Add(new ReportDataSource { Name = "DataSet1", Value = ds.Tables[0] });
            DataSourceCredentials dsc = new DataSourceCredentials();
            dsc.ConnectionString = "Driver={ODBC Driver 17 for SQL Server}; Server=localhost\\SQLEXPRESS;Database=GirlsHaven;MultipleActiveResultSets=true;ColumnEncryption=Enabled;app=reportdatasource;";
            dsc.IntegratedSecurity = false;
            dsc.UserId = "*******";
            dsc.Password = "*******";
            dsc.Name = "GirlsHaven";
            reportOption.ReportModel.DataSourceCredentials.Add(dsc);
            reportOption.ReportModel.ProcessingMode = ProcessingMode.Local;
        }

        public void OnReportLoaded(ReportViewerOptions reportOption)
        {

        }
    }


3 Replies

MS Mahendran Shanmugam Syncfusion Team February 8, 2019 01:10 AM

Hi Justin, 

Thanks for your interest in our Syncfusion products. 

We have validated the mentioned RDLC report is not displaying problem in Report Viewer at our end, we are able to preview the reports properly in ASP.NET Core Report Viewer. We have prepared the simple sample to load the RDLC report with business object datasource and it can be downloaded from below location. So could you please confirm whether the below attached sample is working or not at your end.  

If issue still persists then please revert us by modifying the above attached sample to validate the mentioned problem at our end and provide solution at earliest. 

Regards, 
Mahendran S. 



JU Justin February 8, 2019 04:54 PM

The sample worked and the c# all looked the same, so I suspected it was something in my _Layout.cshtml causing the problem. I created a Layout2.cshtml, copied the sample _Layout to it and had my report view use it. That worked, so there must be a script or css reference missing in _Layout.


RT Ramesh Thangaraj Syncfusion Team February 11, 2019 07:40 AM

Hi Justin, 
  
Thanks for the update. We are happy to hear that your issue is resolved. 
  
Regards, 
Ramesh T. 


Loader.
Live Chat Icon For mobile
Up arrow icon