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
Starting in 2019, the Reporting control is no longer included in Essential Studio. If you're experiencing issues with the Syncfusion Reporting Platform, Report Viewer, Report Designer, or Report Writer, we recommend migrating to Bold Reports, our dedicated reporting platform.

Bold Reports offers a comprehensive suite of tools and features for all your reporting needs, and we will help you make a smooth transition from the discontinued control. Our support team at https://support.boldreports.com/ is here to assist you with any questions or difficulties you may encounter during the migration process.

We thank you for choosing Syncfusion and appreciate your understanding.

Data not binding to Report viewer using ASP.NET MVC

I have used syncfusion report viewer but while loading report in view there is Excepition thrown

the screen snapshot or exception i attached with thread


the view code is:

<link rel='nofollow' href="http://cdn.syncfusion.com/js/web/flat-azure/ej.web.all-latest.min.css" rel="stylesheet" />
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js" type="text/javascript"></script>
<script src="http://cdn.syncfusion.com/js/web/ej.web.all-latest.min.js" type="text/javascript"></script>
<script src=" http://cdn.syncfusion.com/js/web/ej.unobtrusive-latest.min.js" type="text/javascript"></script>

@using Syncfusion.MVC.EJ
@using Syncfusion.JavaScript.Models
@using Syncfusion.JavaScript
@*@using Syncfusion.JavaScript.ReportViewer*@

  <div style="width: 100%">
      @(Html.EJ().ReportViewer("viewer").ProcessingMode(Syncfusion.JavaScript.ReportViewerEnums.ProcessingMode.Local)
.ReportPath("Customer.rdlc")
.ReportServiceUrl("api/ReportApi")
.DataSources(ds => ds.Name("Customer").Value(ViewData["cust"]).Add()))

  </div>


and the code of controlle as :
   public class ReportApiController : Controller, IReportController
    {
        public ActionResult Report()
        {
            ViewData["cust"] = GetList();
            return View();
        }
        public object PostReportAction(Dictionary<string, object> jsonResult)
        {
            return ReportHelper.ProcessReport(jsonResult, this);
        }
        //Get action for getting resources from the report
        [System.Web.Http.ActionName("GetResource")]
        [AcceptVerbs("GET")]
        public object GetResource(string key, string resourcetype, bool isPrint)
        {
            return ReportHelper.GetResource(key, resourcetype, isPrint);
        }
        //Method will be called when initialize the report options before start processing the report
        public void OnInitReportOptions(ReportViewerOptions reportOption)
        {
            //You can update report options here
        }
        //Method will be called when reported is loaded
        public void OnReportLoaded(ReportViewerOptions reportOption)
        {
            //You can update report options here
        }

        [HttpPost]
        public List<CustomerVM> GetDataForReport()
        {
            return GetList();
        }

        private List<CustomerVM> GetList()
        {
            var list = new List<CustomerVM>();

            var cust1 = new CustomerVM { Id = 1, FirstName = "ssss", LastName = "ff", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust2 = new CustomerVM { Id = 2, FirstName = "ddd", LastName = "bbb", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust3 = new CustomerVM { Id = 3, FirstName = "ccc", LastName = "mmm", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust4 = new CustomerVM { Id = 4, FirstName = "ssss", LastName = "ff", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust5 = new CustomerVM { Id = 5, FirstName = "ddd", LastName = "bbb", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust6 = new CustomerVM { Id = 6, FirstName = "ccc", LastName = "mmm", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust7 = new CustomerVM { Id = 7, FirstName = "ssss", LastName = "ff", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust8 = new CustomerVM { Id = 8, FirstName = "ddd", LastName = "bbb", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust9 = new CustomerVM { Id = 9, FirstName = "ccc", LastName = "mmm", MobileNo = "9098908990", Email = "a@gmail.com" };

            list.Add(cust1);
            list.Add(cust2);
            list.Add(cust3);

            list.Add(cust4);
            list.Add(cust5);
            list.Add(cust6);

            list.Add(cust7);
            list.Add(cust8);
            list.Add(cust9);

            return list;
        }

}


and i have set application startup page in Global.aspx.cs:

  public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Login", action = "Login", id = UrlParameter.Optional } // Parameter defaults
            );
          
        }


Attachment: Image1_2744d245.rar

3 Replies

SR Soundara Rajan S Syncfusion Team December 29, 2015 06:26 AM UTC

Hi Dhanashri,

Thanks for contacting Syncfusion support.

In the shared code example, you have inherited the IReportController in MVC controller instead of WebAPI controller. We are internally processing the report based on WebAPI JSON results (RESTFUL Service) and it’s not working with MVC action result. Due to this, you have faced the mentioned issue at your end. So, please inherit the IReportController in your WebAPI instead of MVC controller.

We have prepared standalone based on your requirement and it can be downloaded from below location,
https://www.syncfusion.com/downloads/support/directtrac/142785/MVCReportSample1020409770.zip 
https://www.syncfusion.com/downloads/support/directtrac/148270/ze/ReportViewerMVC5868312663.zip


You can obtain the MVC ReportViewer samples from the below build installed location,
%userprofile%\AppData\Local\Syncfusion\EssentialStudio\$version$\MVC\Samples

Please refer to the below UG documentation for more details,
https://docs.syncfusion.com/aspnetmvc/reportviewer/getting-started

Regards,
Soundara Rajan S


DK dhanashri kadam December 29, 2015 06:37 AM UTC

Thanks for your reply.


SR Soundara Rajan S Syncfusion Team December 30, 2015 05:06 AM UTC

Hi Dhanashri,

Thanks for your response. Please let us know, if you need any further assistance on this.

Regards,
Soundara Rajan S.

Loader.
Live Chat Icon For mobile
Up arrow icon