How to Add Silverlight Viewer to Existing Website

Let’s assume that you have a ready website and you would like to enrich your website with the ability to view the reports. What can you do? The first thing we can think of is to open the sources of the website and write functionality for reports display. Then build the website, test it and deploy on the production server. But to my mind, there is a simpler way to solve this task. You can create a Silverlight application and add it to the current website.

Let’s review how it looks like.

Step 1. Sample Website Creation

Step 2. Embedding the Silverlight Viewer

Step 1. Sample Website Creation

We need to have a “ready” website to integrate the viewer. So we will create a sample. You can go through this section briefly just to understand the structure of the website. Or you can skip this step and start with the Step 2.

We won’t take a large website for our sample: the things that Visual Studio creates when you want to do a website will be enough. 

The project is opened in Visual Studio.

Let’s publish the project on IIS. To do this, select the “Publish Web Site” option from the context menu of the website in the Solution Explorer:

Add the website to IIS. Open control panel of IIS and press the “Add Web Site…” link.

In the opened dialogue window, select the application pool which will be used for a website and indicate the location of a website (a folder where you published your project):


To check if the website works, follow the “Browse *:80 (http)” link:

Main page of the website:


Step 2. Embedding the Silverlight Viewer

Let’s take a Silverlight application delivered with the product package.

The application is located by the following path:

 "C:\Program Files\Perpetuum Software\SharpShooter Collection\Samples\SharpShooter Reports.Silverlight\CSharp\SilverlightDemo_SL4\

Open the sample in Visual Studio.

Let’s modify a project a little bit to make the service address not inside the code but could be modified without the project recompilation.

To do this we should:

1.       In the parameters of the Silverlight application in the “ SilverlightDemo_SL4.Web” project, the “SilverlightDemo_SL4TestPage.aspx” file add the following line:

<param name="initParams" value='<%= String.Format("http://{0}{1}", Request.Url.Authority, ResolveUrl("~/ReportService.svc")) %>'/>


It allows passing the “ServiceUrl” value to a Silverlight application.

2.       Add the line to get the service address from the parameters in the “SilverlightDemo_SL4” project, the “MainPage.xaml.cs”  file:

reportViewer.ServiceUrl = HtmlPage.Plugin.GetProperty("initParams").ToString();


Build the projects by invoking the “Build Solution” from the context menu of the “ SilverlightDemo_SL4” solution.

Make the “Publish” of a web project to make it ready for deploying on a website.

Indicate that “Publish” of the project will be made in the local system.

Let’s also make the Publish of our website where we want to place the Silverlight application.

Now let’s move to publishing of a website on IIS.

Let’s create a folder, for example the “reportviewer” in the folder where we made the “Publish” of the project. Copy files of a Silverlight application there.

Refresh a website in the IIS manager:

You will see the “reportviewer” folder. From the context menu of the “reportviewer” folder select the “Convert to Application” option:

Press “OK”


Let’s add the ability to go to a report preview page to the menu of our website. To do that we add the following line to the menu of the “Site.master” file:

<asp:MenuItem NavigateUrl="~/reportviewer/SilverlightDemo_SL4TestPage.aspx" Text="Reports"/>


Open the website in a browser. In the menu you can see the Reports item. Let’s click it.

And we go to a page with a report.

Add Feedback