An Extended Look at the Profile Object - Part 3
page 1 of 5
Published: 05 Dec 2005
Unedited - Community Contributed
Abstract
This article is the third in the series of articles on the new personalization feature of ASP.NET 2.0, the Profile object. In this article, we are going to discuss the Profile provider-model, which is a new concept implemented by most of the new features in ASP.NET 2.0. In addition, the default SQL Profile provider that is configured with SQL Server 2005 will be studied in depth and a trick on how to use the same provider with SQL Server 2000 will be presented.
by Bilal Haidar
Feedback
Average Rating: 
Views (Total / Last 10 Days): 40444/ 82

Introduction

This article is the third article in the series of articles on the new personalization feature of ASP.NET 2.0, the Profile object.

The first article discussed the basics of a Profile object, how is it different from the Session object, and how to use simple properties in the Profile configuration section in the Web application configuration file (web.config).

The second article discussed more advanced features on how to use the Profile object, mainly, using custom defined objects as Profile objects.

In this article, we are going to discuss the Profile provider-model, which is a new concept implemented by most of the new features in ASP.NET 2.0. In addition, the default SQL Profile provider that is configured with SQL Server 2005 will be studied in depth, and I will present a trick on how to use the same provider with SQL Server 2000.

In the first two parts of this series on the new Profile object in ASP.NET 2.0, we explained the Profile object and implemented all the possible ways in which a Profile object can be configured in the Web application configuration file (web.config).

In this article, we will be looking at more advanced topics including the new Provider model in ASP.NET 2.0, the Profile provider, creating a custom Profile provider, and finally, how to configure the default Profile provider to work with SQL Server 2000.

 

What is a Provider Model?

The new provider model is an interface module between an ASP.NET 2.0 feature and the data store used to store the state of that feature. Providers in ASP.NET 2.0 abstract the physical data storage for a feature from the classes and the business logic exposed by a feature.

Some of the new features in ASP.NET 2.0 are based on a provider model in order to have access to the data store used. ASP.NET 2.0 ships with a default provider for each of the new provider-based features that are configured to work with SQL Server 2005 Express. However, if we want to make the features interact with another data store like SQL Server 2005, Oracle, or another database, then it is as simple as changing some configuration sections in the Web application configuration file (web.config) without having to change any single line of code in the features classes working each with its specific provider. More on the provider model can be found in this article: Introduction to the Provider Model

 

Importance of the Provider Model

The new provider model introduces several advantages in developing Web applications.

  1. It isolates the new features controls from the data store used in the application. The only way for those controls to access the data store is by using that provider.
  2. The application being developed can be used with any data source of choice without having to change any line of code in those features. We only need to create a custom provider and do some configuration changes in the Web application configuration file (web.config).

 

Profile Provider

The Profile feature has been designed with a provider-based model. The Profile feature ships with a provider for Microsoft SQL Server Express. You can create your own custom providers and configure them to work with the Profile feature. Pages that use the Profile objects will continue to work unchanged with your custom providers, since the Profile provider is a middle layer between the data store and the classes that provide the different methods to work with the Profile object.

More over, the Profile feature provides not only the Profile object but also a ProfileManager to manage the Web application Profile objects. This manager can handle both anonymous and authenticated Profile objects. Management of Profile objects includes the following:

  1. Generating statistical information about all Profiles, for authenticated users, as well as for anonymous users.
  2. Determining the number of Profiles that have not been modified in a given period of time.
  3. Deleting individual Profiles as well as deleting multiple Profiles based on a Profile's last modification date.

The diagram below shows the different layers of the new Profile feature in ASP.NET 2.0:

Figure 1 - Profile Layer Diagram

 

As shown in Figure 1 above, the new Profile feature consists of three layers:

  1. Profile classes that provide direct access to the Profile properties.
  2. Profile providers that represent the abstraction layer between the upper layer which is the Profile classes and the lower layer which is the data store(s).
  3. Profile Data Stores that represent the storage medium where the Profile property values are stored. In Figure 1 above, two main data stores are shown: the SQL Server and SQL Server Express. Any other data base can be added by just generating a custom Profile provider.

 

 

The ASP.NET 2.0 Profile provider implements all of the methods and properties that are part of the Profile object and ProfileManager class. Those methods and properties include the following.

  1. ApplicationName is the application name using the Profile provider. Usually profile data are scoped to one application.
  2. GetPropertyValues returns the profile property values from the data store used to store the Profile data.
  3. SetPropertyValues stores the profile property values into the data store configured in the Web application.
  4. DeleteProfiles deletes profile records stored inside the data store configured in the Web application.
  5. DeleteInactiveProfile deletes inactive profile records stored inside the data store configured in the Web application.
  6. GetNumberOfInactiveProfiles returns the number of inactive profile records inside the data store configured in the Web application.
  7. GetAllProfiles returns a collection of ProfileInfo objects containing information about all profiles stored in the data store.
  8. GetAllInactiveProfiles returns a collection of ProfileInfo objects containing information about all profiles stored in the data store that has not been accessed from a specific time.
  9. FindProfilesByUserName returns a collection of ProfileInfo objects containing information about the profiles of a specific username.
  10. FindInactiveProfilesByUserName is similar to the above method; however, it returns a collection of inactive profiles belonging to a certain username.

The above methods and properties are all implemented by the SQL Server Profile provider that is shipped with ASP.NET 2.0. This default Profile provider is configured to be used with SQL Server 2005. In the next section, we will discuss in detail how to make this default Profile provider work with SQL Server 2000.

 


View Entire Article

User Comments

Title: Mtbc   
Name: aamir hasan
Date: 2007-02-06 3:36:00 AM
Comment:
if we include master page and then we can not use multiple form why please explain me
Title: Very nspiring info   
Name: Tahir Aziz
Date: 2006-06-20 2:36:00 PM
Comment:
Very weel .. relaly amazing it helps me a lot.. i am a beginer in ASP dvelopment and its reallly use full for me to have very nice and easy tutorials here on this platfprm..:)
thanks a lot.. i hope for new more inspiring tutorials..With all the best keep it up..!!!
Title: An Extended Look at the Profile Object - Part 3   
Name: raja mohamed
Date: 2006-03-17 2:04:47 AM
Comment:
Good
Title: How delete a single property?   
Name: Massimo
Date: 2005-12-27 8:16:05 PM
Comment:
I cannot find how to delete a user properties from the datastore. Do I miss something?






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2017 ASPAlliance.com  |  Page Processed at 2017-11-20 9:52:48 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search