Live Services SDK
Implementing Personalization

This section explores the source code of the included sample application and explains how it implements automatic personalization. To view the source code for the sample application, open the Microsoft Visual Studio 2005 project on the Start menu.

Bb404796.note(en-us,MSDN.10).gifNote:
To locate shortcuts the sample application and source code, click Start, point to Programs, point to Windows Live ID Client SDK, and then click the desired shortcut. 

Personalization is the storing and loading of user-specific data and settings in an application. In the sample application, users can choose a background color for the application that will be loaded every time that they sign in. Users can also specify that they want to be automatically signed in in the future.

To store user-specific settings such as background color, it is useful to have a permanent, unique identifier associated with individual users. Windows Live ID provides this identifier in the form of the Client ID or cId. Sign-in names may change, but the Client ID for an individual Windows Live ID account remains the same.

Access to the Client ID is provided through the cId property of a currently authenticated Identity object.

To implement personalization, your application must be able to store and retrieve user-specific settings and provide an interface for the user to modify or delete those settings. In your application, you may choose to store the default sign-in name (if any) in a configuration file, the registry, a database, text file, Web service, or any other method that you prefer.

In the sample application, we have chosen to store the default sign-in name and user-specific background color settings in an application configuration file. Configuration files are special XML files that are created and accessed through the .NET Framework configuration system as represented by the classes that are contained in the System.Configuration namespace.

Specifically, we have chosen to use the static AppSettings property of the System.Configuration.ConfigurationManager class together with the AppSettings property of a System.Configuration.Configuration object instance.

The static AppSettings property of the System.Configuration.ConfigurationManager class provides read-only access the AppSettings section of the application configuration file. The AppSettings property of a System.Configuration.Configuration object instance provides additional methods for adding, removing, and modifying application settings. By default, the settings are stored automatically in a configuration file in the same directory as your application as shown in the following example:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <appSettings>
        <add key="1234567890123456_bgColor" value="-128" />
        <add key="defaultUserName" value="user@example.com" />
    </appSettings>
</configuration>

The .NET Framework configuration system automatically handles loading, parsing, and saving changes to the application configuration file. This makes it very convenient for storing, retrieving, and modifying user-specific settings and data. For more information, see ConfigurationManager.AppSettings and Configuration.AppSettings on the MSDN Web site.

In this section

How to Set Up Personalization

How to Implement Personalization

Page view tracker