📒
OpenRiaServices
  • Start
  • Prerequisites for Open Ria Services
    • Walkthrough: Installing and Configuring SQL Server 2008 R2 Express with Advanced Services
    • Walkthrough: Installing the AdventureWorks OLTP and LT sample databases
  • Creating Open Ria Services Solutions
    • Walkthrough: Taking a Tour of Open Ria Services
    • Walkthrough: Creating a Open Ria Services Solution
    • Walkthrough: Creating a Open Ria Service with the Code First Approach
    • Walkthrough: Using the Silverlight Business Application Template
    • Walkthrough: Creating a Open Ria Services Class Library
    • Walkthrough: Localizing a Business Application
    • How to: Create a Domain Service that uses POCO-defined Entities
    • How to: Add or Remove a Open Ria Services Link
    • Using the Domain Service Wizard
  • Building Secure Applications with Open Ria Services
  • Deploying and Localizing a Open Ria Services Solutions
    • Troubleshooting the Deployment of a Open Ria Services Solution
    • Troubleshooting the Deployment of a Open Ria Services Solution
    • Walkthrough: Localizing a Business Application
  • Middle Tier
    • Domain Services
      • Walkthrough: Adding Query Methods
      • How to: Add Business Logic to the Domain Service
      • How to: Create a Domain Service that uses POCO-defined Entities
      • How to: Use HTTPS with a Domain Service
    • Data
      • Compositional Hierarchies
      • Presentation Models
      • Inheritance in Data Models
      • Complex Types
      • Shared Entities
      • Walkthrough: Sharing Entities between Multiple Domain Services
      • How to: Add Metadata Classes
      • How to: Validate Data
      • Managing Data Concurrency
    • Shared Code
      • How to: Share Code through Source Files
      • Walkthrough: Creating a Open Ria Services Class Library
  • Silverlight Clients
    • Client Code Generation
    • DomainContext and Operations
    • DomainDataSource
    • Error Handling on the Client
    • Customizing Generated Code
      • How to: Add Computed Properties on the Client
  • Accessing non-Silverlight Clients
    • ASP.NET Clients
    • Walkthrough: Using the Domain Service in ASP.NET Applications
  • Authentication, Roles, and Profiles
    • How to: Enable Authentication in Open Ria Services
    • How to: Enable Roles in Open Ria Services
    • How to: Enable Profiles in Open Ria Services
    • How to: Create a Custom Authorization Attribute
    • Walkthrough: Using Authentication Service with Silverlight Business Application
    • Walkthrough: Using Authentication Service with Silverlight Navigation Application
  • End-to-EndScenarios
    • Walkthrough: Retrieving and Displaying Data From a Domain Service
    • Walkthrough: Editing Data From a Domain Service
    • Walkthrough: Displaying Data in a Silverlight Business Application
    • Walkthrough: Displaying Related Data in a Silverlight Business Application
Powered by GitBook
On this page
  • To configure the server project
  • To access profile properties from the client project
  • See Also

Was this helpful?

  1. Authentication, Roles, and Profiles

How to: Enable Profiles in Open Ria Services

PreviousHow to: Enable Roles in Open Ria ServicesNextHow to: Create a Custom Authorization Attribute

Last updated 4 years ago

Was this helpful?

[ This document was written for WCF Services Version 1 Service Pack 2 and might not be up to date Please see or 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 .

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 .

To configure the server project

  1. In the server project, open the Web.config file.

  2. In the \ section, add a \ element.

  3. In the \ element, add profile properties.

    The following example shows how to enable a profile and define a property named FriendlyName.

    <system.web>
      <authentication mode="Forms"></authentication>
      <profile enabled="true">
        <properties>
          <add name="FriendlyName"/>
        </properties>
      </profile>
    </system.web>
  4. Open the file that contains the User class for the authentication service.

  5. 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.

    Partial Public Class User
        Inherits UserBase
    
        Private _FriendlyName As String
    
        <DataMember()> _
        Public Property FriendlyName() As String
            Get
                Return _FriendlyName
            End Get
            Set(ByVal value As String)
                _FriendlyName = value
            End Set
        End Property
    End Class
    public partial class User : UserBase
    {
    
        [DataMember]
        public string FriendlyName { get; set; }
    }

To access profile properties from the client project

  1. In the Silverlight client project, open a code-behind page.

  2. 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.

    WebContext.Current.User.FriendlyName = "Mike"
    WebContext.Current.User.FriendlyName = "Mike";
  3. 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.

    Private Sub Application_Startup(ByVal o As Object, ByVal e As StartupEventArgs) Handles Me.Startup
        Me.Resources.Add("WebContext", WebContext.Current)
        Me.RootVisual = New MainPage()
    End Sub
    private void Application_Startup(object sender, StartupEventArgs e)
    {
        this.Resources.Add("WebContext", WebContext.Current);
        this.RootVisual = new MainPage();
    }

    Using declarative syntax, you can retrieve the profile property. The following example shows how to retrieve a profile property in XAML.

    <TextBlock Text={Binding Source={StaticResource WebContext}, Path=User.FriendlyName}"/>

See Also

Tasks

Release Notes
Changelog
ASP.NET Profile Properties Overview
How to: Enable Authentication in Open Ria Services
Walkthrough: Using Authentication Service with Silverlight Navigation Application
Walkthrough: Using Authentication Service with Silverlight Business Application