Combining ASP.Net MVC With SQL Server Reporting Services

Hi everyone in this blog I’m explaining about Reporting Services in ASP.NET MVC.


There is no control for Report Viewer in MVC, so we cannot view a report using MVC applications. Most business applications have report requirements. In article, I will explain the work around to make it happen. Here I will assume that we already have a report server with some test report.

MVC does not provide a Report Viewer control so we need to add a classic web form page to our MVC application. The recommendation is to place this form outside of the view folder so that we don't need to register or ignore the route.

In this classic web form page, we need to add the following two controls:

  1. Script manger
  2. Report Viewer control


ReportViewer.aspx code:


<form id="form1" runat="server">

        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>


            <rsweb:ReportViewer ID="rptViewer" runat="server" Height="503px" Width="663px">





The following Procedure is required to write a report render function: 

  1. Set processing mode to remote.
  2. Pass report server URL and report path.
  3. Pass the parameters if any.
  4. Pass Credential of Report Server if required.
  5. Refresh the report.

The following is the show report function:

private void ShowReport()




                //report url 

                string urlReportServer = "http://localhost:57370//Reportserver";


                rptViewer.ProcessingMode = ProcessingMode.Remote;


                rptViewer.ServerReport.ReportServerUrl = new Uri(urlReportServer);


                rptViewer.ServerReport.ReportPath = "~/Home/Report/TestReport.txt";




            catch (Exception ex)


                throw ex;



In the page load event of the Report Viewer page, call the preceding function to render the report. In this example, we are passing the hardcoded report name. Instead of this we can pass the report name using any state management technique.

Report Viewer page Code:


public partial class ReportViewer : System.Web.UI.Page


        protected void Page_Load(object sender, EventArgs e)






Now we need to call this view from our controllers. For that I have created an ActionResult and called it from the menu.

Controller Code:

public ActionResult Index()


            return View();


        public ActionResult ShowReport()


            return Redirect("~/ReportViewer/ReportViewer.aspx");




in my next post i'll explain about Introduction Angularjs

Leave Comment