Using SQL Server Reporting Services in MVC Web Application

By | September 25, 2012

You might be wondering how to use SQL Server Reporting Services Reports with an MVC Application hence you’re in this page, well let me explain to you in this simple steps

At the time of this post there is no controls yet for Report Viewer in MVC so we will be doing some workaround to make it happen. I will also assume that you already have a Reporting Server with reports in place so I will not discuss that section

Lets start.

First is you need is a Classic Web Form where you will include the Report Viewer, I suggest to place it outside of your view folder so you don’t have to register or ignore a Route.  In my case I added it in a folder outside the view called Content, this is where I store my images as well as other documents that a part of the whole project.

Let us name it ReportingServices.aspx

Now go to your design view and add a Script Manager an Report Viewer

Now go to code view and give it the right ReportPath and ReportServerUrl

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

<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" 
    Font-Size="8pt" InteractiveDeviceInfos="(Collection)" ProcessingMode="Remote" 
    WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Height="100%" 
    <ServerReport ReportPath="/YourApplicationName/YourReportName" 
        ReportServerUrl="http://yourserver/ReportServer" />

Now you have your viewer, now lets use it in your view

Create a view and lets call it SampleReport.cshtml

Inside that view use an IFrame with the source pointing to the path of your ReportingServices.aspx (I will leave the adjusting of height and width with you)

Now you have your view all you need is call it from your controller, lets create an ActionResult and call it GetSampleReport.

public class ReportsController : Controller

    public ActionResult Index()
        return View();

    public ActionResult GetSampleReport()
        return View("SampleReport");

There you have it you can now run a report within an MVC application


7 thoughts on “Using SQL Server Reporting Services in MVC Web Application

  1. Shalu

    Awesome article. Do you know how to display the report on a new window/page. Its rendering the report on the same window/page

  2. Miguel Angel Garcia

    Thanks and Hi from Mexico, i am having this error “Sys.WebForms.PageRequestManagerParserErrorException: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.” because I am giving parameters to the report inside the report viewer what can I do?

  3. Vanaja

    This is the Very good Post for Integrating SSRS reports in MVC.
    This is the best ever solution. Thank you very much.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.