Deploying Silverlight application with RIA services enabled

Deploying a Silverligtht application with WCF services and RIA services can be a time consuming process and may require extensive research on forums and MSDN. Here are just some of the tips I figured out recently.

To deploy a Silverlight application with RIA services on Windows 7/Windows 2008, follow the steps outlined below:

1. Run Visual Studio as Administrator: Right-click the Visual Studio shortcut and choose Run as Administrator. This is required for obtaining proper system permissions when publishing applications to the IIS inetpub folder. If you want to set up always running the Visual Studio 2010 as administrator in Windows 7, go to the Microsoft Visual Studio 2010 shortcut, right-click and choose Properties. Then switch to the Compatibility tab and check the Run this program as an administrator option in the Privilege level section.

2. Open the Silverlight solution: File > Open Project/Solution.

3. Right-click the ProjectName.Web and choose Publish. Choose as publish method the File System. Point to the folder to which the application will be published. Check the Delete all existing files prior to publish to make sure that all existing files within the folder will be deleted.

4. Open IIS Manager: To open IIS Manager from the Start menu – click Start, and then click All Programs. Click Administrative Tools, and then click Internet Information Services (IIS) Manager. To open IIS Manager from the Search box – click Start. In the Start Search box, type inetmgr and press ENTER. Go to the Default Web site. Right-click the folder where the application was published to and choose Convert to application. In the Add application dialog box, choose ASP.NET v4.0 application pool and not ASP.NET v4.0 Classic.

If for some reason, you are missing these pools even though you have .NET Framework 4 installed, you can fix this by registering ASP. Open your command prompt and run: cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\. Then run: aspnet_regiis.exe -ir.

5. Right-click the application folder in the IIS manager and select Switch to content view.

Select .html or .aspx file and choose Browse in the Actions panel.

6. You will get an error message, because the RIA service was not created yet on-the-fly.

7. In order to make the application run as designed, you have to create a service in the Web browser first. Open an instance of Internet Explorer, and go to the URL:

http://machinename/appname/<Projectname>-Web-Services-<name of the service file>

Name of the service file can be obtained from the Visual Studio Solution Explorer: Go to <ProjectName>.Web and then expand Services folder to see the name of the created service.

Your URL may look like this: http://localhost/SL_Work/SlEventManager-Web-Services-EventManagerDomainService.svc. The URL may look different depending on the structure of the files in the Solution Explorer, so adopt this example. Going to this URL is crucial because you will not be able to view the application correctly without creating the service first.

Select .html or .aspx file in the IIS Manager and choose Browse in the Actions panel.

8. If you get an error saying related to the local user profile, check what authentication settings you have for the application. Opet IIS Manager and go to your application and then select Authentication in the Features view. You should have disabled: ASP.NET Impersonation, Windows Authentication and Basic Authentication. You should have enabled: Forms Authentication and Anonymous Authentication.

9. Now you can select .html or .aspx file in the IIS Manager and choose Browse in the Actions panel.

Hopefully it works!

Advertisements

2 thoughts on “Deploying Silverlight application with RIA services enabled

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s