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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how to set reportOption.ReportModel.Stream = inputStream; from view in mvc

Thread ID:





143937 Apr 11,2019 04:51 AM UTC Apr 11,2019 01:07 PM UTC Report Platform 1
Tags: Report Viewer
Asked On April 11, 2019 04:51 AM UTC

I'm using ASP Core MVC
In my controller I set the location of the rdl in

        public void OnInitReportOptions(ReportViewerOptions reportOption)
            string basePath = _hostingEnvironment.WebRootPath;
            FileStream inputStream = new FileStream(basePath + @"\Report.rdl", FileMode.Open, FileAccess.Read);
            reportOption.ReportModel.Stream = inputStream;


The only thing that will change for each report is the rdl name, so if possible I'd like to use the same controller for every report instead of recreating essentially the same Controller over and over along with the associated View folders. Is it possible to either set the report file name in the view ej-report-viewer tag or maybe reportOptions has some sort of UDF I can set to Report.rdl? Although I'm open to any other sort of work around like a Case or IF statement inside OnInitReportOptions.

Mageshyadav M [Syncfusion]
Replied On April 11, 2019 01:07 PM UTC

Hi Justin, 
We can able to change the report path and render the report in same controller. We have prepared the simple sample with drop down list to change the report dynamically when using the setModel method in client side and it can be downloaded from below location.  
Please find the below code example for how to change the reports using setModel method in client side.  
@using Syncfusion.JavaScript  
    ViewData["Title"] = "Syncfusion ReportViewer control";  
<select id="dropdown1">  
    <option value="GroupingAgg">GroupingAgg</option>  
    <option value="Sales Order Detail">Sales Order Detail</option>  
<div style="align-items:flex-start; height:100px;width:100px">  
    <ej-drop-down-list id="dropdown1" selected-item-index="0" change="onChange"></ej-drop-down-list>  
<div style=" align-items:center; height:525px;width: 100%;">  
    <ej-report-viewer id="reportviewer1" report-service-url="../Home" report-path="/ReportsTemplate/GroupingAgg.rdl"processing-mode="Remote" />  
<script type="text/javascript">  
        function onChange(args) {  
            reportpath = "/ReportsTemplate/" + args.selectedValue + ".rdl";  
            var reportObject = $("#reportviewer1").data("ejReportViewer");  
                reportPath: reportpath  
Please find the below code example for how to pass that report path to get the stream in controller side.  
        public void OnInitReportOptions(ReportViewerOptions reportOption)  
            string basePath = _hostingEnvironment.WebRootPath;  
            FileStream inputStream = new FileStream(basePath + reportOption.ReportModel.ReportPath, FileMode.Open, FileAccess.Read);  
            reportOption.ReportModel.Stream = inputStream;  


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon