ASP.NET MVC 5 – Embedded SSRS Report by ReportViewerForMvc

ASP.NET MVC 5 – Embedded SSRS Report by ReportViewerForMvc

1. Get and Add the Following Library on the Project First.
 
– Microsoft.ReportViewer.Common ( v11.0.0.0 – from Nuget )
– Microsoft.ReportViewer.DataVisualization ( v11.0.0.0 – from Nuget )
– Microsoft.ReportViewer.ProcessingObjectModel ( v11.0.0.0 – from Nuget )
– Microsoft.ReportViewer.WebForms ( v11.0.0.0 – from Nuget )
– Microsoft.SqlServer.Types ( v11.0.0.0 – from Nuget )
– ReportViewerForMvc ( v1.0.1.0 – from Nuget )
– Entity Frameworks
 
2. Prepare the Entity Framework as a Data Access Layer to Microsoft SQL Server …
 
3. Prepare the Code as a Business Object Layer with a Function which would return the Data Collection in IEnumerable Data Type from Entity Framework Data Access Layer.
 
4. Create a Report Wizard Item from the Web Application Project by using Visual Studio.
 
5. Assign the Prepared Function Name and the Class Namespace as an Available Datasets and Data Source from the Report Wizard Configuration.
 
6. Design & Prepare the Report Content by using the Data Model under the Available Datasets …
 
7. Add the Following Code on web.conf & Controller & View

 
   <system.web>
 
      … …
 
      <httpModules>
 
         … …
 
         <add path="Reserved.ReportViewerWebControl.axd"
            verb="*"
            type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms,
                       Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
            validate="false" />
 
      </httpModules>
 
   </system.web>
 
   <system.webServer>
 
      <handlers>
 
         … …
 
         <add name="ReportViewerWebControlHandler"
            preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd"
            type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms,
                       Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
 
      </handlers>
 
      … …
 
   </system.webServer>
 
 
   public ActionResult Index()
   {
      … …
 
      ViewBag.UserReportData = service.getAllUser();
 
      … …
 
      return View();
   }
 
 
   @Html.ReportViewer(
      new { ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local },
      new { ReportPath = @".. ..\Report\UserReport.rdlc" },
      null,
      new { Name = "UserDataSet", Value = ViewBag.UserReportData },
      null
   )