how to integrate SSRS in mvc from scratch ?

How to integrate SSRS with MVC from scratch?

Asked by:- SnehalSawant
: 6799 At:- 11/19/2017 3:25:34 PM mvc sql mvc ssrs report viewer sample ssrs report in step by step

beginner to ssrs 0
By : SnehalSawant - at :- 11/19/2017 3:33:15 PM

3 Answers
profileImage Answered by:- pika

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

If you have already created reports in database, and just need to integrate it in MVC application, you can find the integration here

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

      <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=XXXXXXXXXXXXXXXX" validate="false"/>

(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:

      <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>

4. Add <dependentAssembly> in <assemblyBinding> Section of <runtime> section same as below. (if its already exists then ignore).

    <assemblyIdentity name="Microsoft.ReportViewer.Common"
    <bindingRedirect oldVersion="" newVersion=""/>
    <assemblyIdentity name="Microsoft.ReportViewer.WebForms"
    <bindingRedirect oldVersion="" newVersion=""/>

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.

At:- 11/19/2017 3:49:22 PM Updated at:- 11/19/2017 4:00:46 PM

profileImage Answered by:- Vinnu

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.

At:- 10/31/2018 5:07:01 AM

Login/Register to answer
Register directly by posting answer/details

Full Name *

Email *

By posting your answer you agree on privacy policy & terms of use