How to: Enable Profiles in Open Ria Services
[ 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 ]
This topic demonstrates how to enable profiles in your Open Ria Services solution if you have previously enabled authentication. Using profiles, you can retrieve and save properties for a user. Profiles in Open Ria Services build upon the profiles framework in ASP.NET. For more information about ASP.NET profiles, see ASP.NET Profile Properties Overview.
You can retrieve or save user profile properties only after the user has been authenticated. To configure the server and client projects for authentication, see How to: Enable Authentication in Open Ria Services.
To configure the server project
In the server project, open the Web.config file.
In the \ section, add a \ element.
In the \ element, add profile properties.
The following example shows how to enable a profile and define a property named FriendlyName.
Open the file that contains the User class for the authentication service.
In the User class, add all of the profile properties that you added to the Web.config file.
The following example shows how to add a property named FriendlyName that matches the property added to the Web.config file.
To access profile properties from the client project
In the Silverlight client project, open a code-behind page.
In the code-behind page, set or retrieve profile properties on the User object of the current instance of WebContext.
The following example shows how to set a profile property in a code-behind file.
If you want to make the WebContext object available in XAML, add the current WebContext instance to the application resources in the Application.Startup event before creating the root visual.
The following example shows how to add the WebContext instance as an application resource.
Using declarative syntax, you can retrieve the profile property. The following example shows how to retrieve a profile property in XAML.
See Also
Tasks
Walkthrough: Using Authentication Service with Silverlight Navigation Application
Walkthrough: Using Authentication Service with Silverlight Business Application
Last updated