There was requirement of reports integration with an MVC application.
I am using MVC Report viewer from code plex MVC Report Viewer
Initially i was using the rdl file as Server Report, which was hosted on Reports Server. I was able to load the reports.
But the requirements were not to host it as Server Report, instead add the rdl file as a local report and load it during run-time.
I did the code changes as follows to load it as Local Report.
ReportViewer reportViewer = new ReportViewer();
reportViewer.ProcessingMode = ProcessingMode.Local;
var dataSet = this.FillDataSet(reportModel.ReportParameters);
reportViewer.LocalReport.ReportPath = string.Format(@"{0}Reports\{1}.rdlc", this.Request.MapPath(this.Request.ApplicationPath), reportModel.ReportName);
reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DS_Report", dataSet.Tables[0]));
reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DS_ChartforSalesRep", dataSet.Tables[0]));
reportViewer.ShowParameterPrompts = false;
reportViewer.DataBind();
reportViewer.LocalReport.Refresh();
reportViewer.ReportError += this.OnLoadReportError;
this.ViewBag.ReportViewer = reportViewer;
Data is loaded and populated into a dataset which is then provided to the report.
I am getting an exception at this line
reportViewer.DataBind();
Tried to find some help online, and most of them suggested to add scripts tag as below
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
Few links - Link 1 - Link 2 - Link 3
The ReportViewerWebForm.aspx
which gets added from the nuget package already had the script tag.
But still, it throws the exception The Report Viewer Web Control requires a System.Web.UI.ScriptManager on the web form
Edit 1: Content of ReportViewerWebForm.aspx
<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="ReportViewerWebForm.aspx.cs" Inherits="ReportViewerForMvc.ReportViewerWebForm" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body style="margin: 0px; padding: 0px;">
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Assembly="ReportViewerForMvc" Name="ReportViewerForMvc.Scripts.PostMessage.js" />
</Scripts>
</asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server"></rsweb:ReportViewer>
</div>
</form>
</body>
</html>
Would be great if someone could help me on this.