First, develop a SSRS report, deploy it to Report Manager, and run the report to confirm that it works properly. Create/open an ASP.NET Web Application. Create/open a Web Form in Visual Studio:

Toolbox -> Reporting. Drag a ReportViewer control onto the Web Form.

Ensure that adding the ReportViewer to the page caused the following updates (you will have to reload web.config if it is already open in Visual Studio):

  1. A new reference for Microsoft.ReportViewer.WebForms was added in: Solution Explorer -> MySolution -> References
  2. A new register assembly directive was added to the .aspx form:
    1. <%@ Register Assembly=”Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” Namespace=”Microsoft.Reporting.WebForms” TagPrefix=”rsweb” %>
  3. The web.config file has the following XML elements (highlighed in bold text):

 

<?xml version=”1.0″?>

<configuration>
<connectionStrings>
<add name=”ApplicationServices”
connectionString=”data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true”
providerName=”System.Data.SqlClient” />
</connectionStrings>

<system.web>
<httpHandlers>
<add path=”Reserved.ReportViewerWebControl.axd” verb=”*” type=”Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”
validate=”false” />
</httpHandlers>
<compilation debug=”true” targetFramework=”4.0″>
<assemblies>
<add assembly=”Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A” />
<add assembly=”Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A” />
<add assembly=”Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A” />
<add assembly=”System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A” />
</assemblies>
<buildProviders>
<add extension=”.rdlc” type=”Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” />
</buildProviders>
</compilation>

<authentication mode=”Windows”>
<forms loginUrl=”~/Account/Login.aspx” timeout=”2880″ />
</authentication>

<membership>
<providers>
<clear />
<add name=”AspNetSqlMembershipProvider” type=”System.Web.Security.SqlMembershipProvider” connectionStringName=”ApplicationServices” enablePasswordRetrieval=”false” enablePasswordReset=”true” requiresQuestionAndAnswer=”false” requiresUniqueEmail=”false” maxInvalidPasswordAttempts=”5″ minRequiredPasswordLength=”6″ minRequiredNonalphanumericCharacters=”0″ passwordAttemptWindow=”10″ applicationName=”/” />
</providers>
</membership>

<profile>
<providers>
<clear />
<add name=”AspNetSqlProfileProvider” type=”System.Web.Profile.SqlProfileProvider” connectionStringName=”ApplicationServices” applicationName=”/” />
</providers>
</profile>

<roleManager enabled=”false”>
<providers>
<clear />
<add name=”AspNetSqlRoleProvider” type=”System.Web.Security.SqlRoleProvider” connectionStringName=”ApplicationServices” applicationName=”/” />
<add name=”AspNetWindowsTokenRoleProvider” type=”System.Web.Security.WindowsTokenRoleProvider” applicationName=”/” />
</providers>
</roleManager>

</system.web>

<system.webServer>
<modules runAllManagedModulesForAllRequests=”true” />
<validation validateIntegratedModeConfiguration=”false” />
<handlers>
<add name=”ReportViewerWebControlHandler” preCondition=”integratedMode” verb=”*” path=”Reserved.ReportViewerWebControl.axd” type=”Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” />
</handlers>
</system.webServer>
</configuration>

Get the value that we will use for the ReportViewer “ReportPath” property. Browse to an existing published report in Report Manager, copy the ItemPath value from the URL in the address bar. Replace all URL escape codes with the escaped characters. Example: “%2fMyFirstFolder%2fMySecondFolder%2fMy+Report+Name” becomes “/MyFirstFolder/MySecondFolder/My Report Name”.

Get the value that we will use for the ReportViewer “ReportServerUrl” property: Start -> (All Programs) -> Microsoft SQL Server -> Configuration Tools -> Reporting Services Configuration Manager. Enter the Server Name, click “Find”, select the Report Server Instance, and click “Connect”. Click “Web Service URL” in the left menu, then click the blue URL link on the page. The link should open in a browser and you should see the file system contents of your SSRS root folder. Copy the URL from the address bar in the browser. The link will probably be similar to: http://myReportServer/ReportServer.

Visual Studio -> MyWebForm.aspx -> Design mode -> ReportViewer -> Properties. Expand the “ServerReport” property. Set the following 2 properties:

  1. Set the “ReportServerUrl” property to the value that we determined in a previous step.
  2. Set the “ReportPath” property to the value that we determined in a previous step.
  3. Set the “ProcessingMode” property to “Remote” (this may not be necessary, based on your server architecture)

Visual Studio -> Toolbox -> AJAX Extensions: drag a ScriptManager control onto the web form. The ScriptManager does not require any configuration, it just needs to exist on the form.

Run the web application, browse to the web form containing the ReportViewer. You should see the report embedded in the Web Form.

Advertisements