In this article, we will cover how to use the deployed SSRS Report on to the ASP.NET Web application. In our earlier articles we have seen the steps to create and deploy the report to the Reporting Server and administer the deployed reports. In real time, we have seen requirements on accessing the reports from different clients. Let us now move ahead for the step-by-step process on accessing the SSRS report in ASP.NET web pages dynamically.
Before starting the steps to show the SSRS Report in ASP.NET Page, we should just have a look around on the previous articles to get some fair idea on how to design the report and deploy it to the Report Server.
First, open visual studio 2010 IDE and create a new ASP.NET Project as shown in the screen below. In this example we are going to use the report which we deployed in the Part 2 of this series of articles on SSRS.
Now in the ASPX Page, drag and drop a Scriptmanager tool, a button and a report viewer control from the toolbox as shown in the screen below.
Double click on the button. This will open a button event as shown in the screen below.
In the button click event we need to write our custom code to access the report from the SSRS Server as shown in the screen below.
reportViewerSam.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
reportViewerSam.ServerReport.ReportServerUrl = new Uri("http://sp2010/ReportServer");
reportViewerSam.ServerReport.ReportPath = "/Part2Sample/Report1";
In the above code, we can have the Report Server URL http://sp2010/ReportServer which we need to change as per the server URL. The report path on which the report is deployed is /Part2Sample/Report1. Also, since we are accessing the server directly we need to provide the processing mode as Remote. Once we are done with the above code, execute the project by clicking the Run button or press F5 (functional key) as shown in the screen below.
Once the project is build successfully, we can see only the button as shown in the screen below.
Now click on Get Reports to access the report directly from the SSRS server. Clicking on Get Report will load the report and we can see the report generating as shown in the screen below.
Once the report is generated completely, we can see the report with the well formatted structure that has been deployed to the sever as shown in the screen below.
So, in this article we have seen how to show the deployed SSRS Report in the asp.net web application with ease without doing any formatting or any design.