I followed Dykstra’s tutorial series to switch form web forms development to MVC. I did not see anywhere in that tutorial or any other resources I found on the web how to provide reports via rdlc, outputting PDF, Excel, ReportViewer, …. I do know how
to choose which output to use.
I have a data context say MyContext with associated models, including reasons.cs. I want to simply list the items in the Reason table. I created a web form containing the script manager and the reportVIewer.
How do I get to the info in the model to designate it as the recordset to use for the report? Is everything done in the forms’c CodeBehind or is there a better way to integrate the MVC with the ReportViewer? I have seen various examples of some ways to
do so, but none were successfully using references to the model but rather creating separate new datasets.
AFAIK You cannot directly show an SSRS Report in MVC application.The ReportViewer control requires ViewState to work, so you can’t place it in an MVC view.This doesn’t mean you can’t use it in your website, however You’ll just have to mix in a little bit
of classic WebForms(aspx) and use the ReportViewer there.
As a solution you can try the below mentioned steps
Add a webform page(Reports.aspx) to your solution and then load your reportviewer control and attach the ssrs report to the Reportviewer control. Next
We need to have a place holder which will load the aspx page in MVC3 Razor. Use iframe for loading the aspx page
Add an iframe to your .cshtml page and assign the src to point to Reports.aspx page.
<iframe runat="server" id="Reports" src="~/Reports.aspx" width="95%" height="460"></iframe>
Check the below links
- ASP.NET MVC – Handling SSRS reports with ReportViewer – Part I
- Incorporating ASP.NET MVC and SQL Server Reporting Services,
Apart from this you can also check MvcReportViewer which is available in Nugget.