Walkthrough: Using the Silverlight Business Application Template
Last updated
Last updated
[ This document was written for WCF Services Version 1 Service Pack 2 and might not be up to date Please see Release Notes or Changelog for a list of changes since WCF RIA Services ]
In this walkthrough, you will learn how to create a Open Ria Services solution by using the Silverlight Business Application template. This walkthrough shows how to create the application and how to use several of the features that are made available by the template with very little additional work. It also shows how to switch from the default authentication mode of Forms Authentication to Windows Authentication.
The Silverlight Business Application template creates a project that automatically includes many features that you typically want in a business application, such as controls to log in users and to register new users. The project created by the template is also set up to use Silverlight navigation, which means you can easily add new Silverlight pages for additional functionality.
By default, the Silverlight Business Application template enables authentication, roles, and profiles. The default authentication mode used by the template is Forms Authentication, but you can change the authentication mode to Windows Authentication by simply changing two configuration values. The procedure for making this change is provided here.
For more information about how to use the services for authentication, roles, and profiles supported in a Open Ria Services application, see the topics in the Authentication, Roles, and Profiles section.
This and the other walkthroughs presented in the Open Ria Services documentation require several prerequisite programs, such as Visual Studio and the Silverlight Developer Runtime and SDK, be installed and configured properly, in addition to Open Ria Services and the Open Ria Services Toolkit. They also require installing and configuring SQL Server 2008 R2 Express with Advanced Services and installing the AdventureWorks OLTP and LT database.
Detailed instructions for the satisfaction of each of these prerequisites are provided by the topics within the Prerequisites for Open Ria Services node. Follow the instructions provided there before proceeding with this walkthrough to ensure that you encounter as few problems as possible when working through this Open Ria Services walkthroughs.
In Visual Studio, select File, New, and then Project.
The New Project dialog box appears.
Select the Silverlight project type.
Select the Silverlight Business Application template and name the application ExampleBusinessApplication.
Click OK.
Notice the project structure that is created. The Silverlight client project includes Silverlight pages in the Views folder. These pages enable logging in users and registering new users.
In Solution Explorer, right-click the Silverlight client project and select Properties.
The Silverlight tab of the project designer appears. At the bottom of the tab, notice that a Open Ria Services link exists between the client and server projects.
Build and run (F5) the application.
The home page of the application appears in your browser.
Click the login link.
The Login dialog box appears.
Click the Register now link.
The Register dialog box appears.
Add values to register a new user.
Click OK to create the new user.
Notice that you are now logged in as the user you registered.
Close the browser.
In the server project, open the Web.config file.
In the authentication element, set the mode property to Windows and remove the forms element.
In the client project, open the code-behind file (App.xaml.cs or App.xaml.vb) for the App.xaml file.
In the constructor, uncomment the line that sets the Authentication property to WindowsAuthentication and comment out the line that sets the property to FormsAuthentication.
Build and run (F5) the application.
Notice that you are now logged in with your Windows account. The Silverlight Business Application includes code in the Application_Startup method that attempts to load the user for Windows Authentication.
Walkthrough: Displaying Data in a Silverlight Business Application
Walkthrough: Displaying Related Data in a Silverlight Business Application