O'Reilly logo

Learning ASP.NET 2.0 with AJAX by Dan Hurwitz, Jesse Liberty, Brian MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Personalization

Personalization allows the user to modify your site to reflect his or her own tastes. It also allows you to keep track of the user's "progress" through a sequence of steps or selections made on a page from one visit to another. Many sites use personalization to create persistent "wish lists," "shopping carts," and so forth.

This used to be a huge and complicated job—keeping track of a user's set of preferences and the state of a user's personal information. Fortunately, that is all made easier now with ASP.NET 2.0.

Profiles

Copy the previous example, SecurityRoles, to a new web site called SitePersonalization. Set Welcome.aspx as the start page and run it to make sure everything still works.

One of the easiest ways to personalize a site is to define profile information that you will maintain for each user. Profile information can include such simple data as the user's real name, address, and telephone numbers, or, as you'll see later, it can include more complex user-defined data.

Simple data types

To use profiles, you have to make some modifications to your web.config file for the project. The first step is adding a new section called <profile>, setting the enabled property to true, and specifying defaultProvider as AspNetSqlProfileProvider. The defaultProvider property holds the data for the profiles; AspNetSqlProfileProvider is the built-in provider for ASP.NET.

Then you need to modify web.config to indicate which pieces of profile information to save. You add a <properties> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required