16.1. Understanding Profile

The ASP.NET Profile is another application service that ships with ASP.NET. It enables you to store and retrieve information about users to your site that goes beyond basic information like an e-mail address and password that users can enter during sign-up, as you learned in the previous chapter. With Profile, you can store information like a first and last name, a date of birth, and much more, as you'll see later in this chapter. By keeping track of the user that the data belongs to, ASP.NET is able to map that data to a user the next time she visits your site, whether that be minutes or weeks later. The cool thing about Profile is that it allows you to store data for registered users as well as anonymous users. So, even if your visitors haven't signed up for an account, you can recognize them and store information about them.

You access the properties of the Profile through a clean API with virtually no code. All you need to do is define the information you want to keep track of in the central web.config file and then the Profile feature takes care of the rest. All interaction with the database to retrieve or store the profile information in the database is handled automatically for you.

Enabling Profile in your web application is a simple, three-step process:

  1. Define the information you want to store for a user in the web.config file.

  2. Based on this information, the ASP.NET runtime generates and compiles a class for you on the fly that gives you access ...

Get Beginning ASP.NET 3.5: In C# and VB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.