How to integrate SSRS with MVC from scratch?
To make it easier and what usually programmer does it that you would need to create a add web form(Single web form page) in MVC and then call it using ActionMethod to display SSRS report, you can find very good explanation of that here
http://www.codemag.com/article/1009061
If you have already created reports in database, and just need to integrate it in MVC application, you can find the integration here
http://techbrij.com/ssrs-report-asp-net-mvc-app
a. Install Report Viewer from Nuget using Command
PM> Install-Package ReportViewerForMvc
b. Update your web.config as below
1. Add following in <appSettings> Section.
<add key="ReportPath" value="/MyReports/"/>
2. Add following httpHandlers in <system.web> Section same as below
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXXXXXXXXX" validate="false"/>
</httpHandlers>
(Please be-aware with the version of .dll file when including above line in web.config file).
3. Add following handlers in <system.webServer> Section same as below:
<handlers>
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</handlers>
4. Add <dependentAssembly> in <assemblyBinding> Section of <runtime> section same as below. (if its already exists then ignore).
<dependentAssembly>
<assemblyIdentity name="Microsoft.ReportViewer.Common"
publicKeyToken="89845dcd8080cc91"/>
<bindingRedirect oldVersion="10.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.ReportViewer.WebForms"
publicKeyToken="89845dcd8080cc91"/>
<bindingRedirect oldVersion="10.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
</dependentAssembly>
Then, create ActionResult with the name of Report and add their view by right-clicking on controllerName.
public ActionResult Report()
{
ReportViewer rptViewer = new ReportViewer();
// ProcessingMode will be Either Remote or Local
rptViewer.ProcessingMode = ProcessingMode.Remote;
rptViewer.SizeToReportContent = true;
rptViewer.ZoomMode = ZoomMode.PageWidth;
rptViewer.Width = Unit.Percentage(99);
rptViewer.Height = Unit.Pixel(1000);
rptViewer.AsyncRendering = true;
rptViewer.ServerReport.ReportServerUrl = new Uri("http://localhost/ReportServer/");
rptViewer.ServerReport.ReportPath = this.SetReportPath();
ViewBag.ReportViewer = rptViewer;
return View();
}
Then update your Report.cshtml view with following.
@if (ViewBag.ReportViewer != null)
{
@Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer)
}
Add required using reference if any.
Do not forget to include @using ReportViewerForMvc; in your View.
Here is the link which explains more about Displaying SSRS (Sql server reporting services) in ASP.NET MVC View with step by step procedure and have attached sample project.
Hi,
You need to add reportviewer. Check the below given links:
http://www.aspmantra.com/2017/08/asp.net-mvc-create-rdlc-report-aspmantra.html
http://www.aspmantra.com/2017/08/how-to-pass-parameter-to-rdlc-report-in-asp.net-mvc-aspmantra.html
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly