ASP.NET 2.0 : Tired with Sessions? - Use the new Profile property to store user information.

All of us who write web application enforce some mechanism by which we store a user's information for the period he is accessing the application. This may be from simply storing the User's ID to say a Welcome <username> to maintaining his preferences, shopping cart etc.,

So far, the Session object has been pretty useful to accomplish this task. With Whidbey (ASP.NET 2.0), there is a new feature Profile which allows us to store per-user settings to be used throughout the application. Settings can also be stored in an anonymous profile while users are not logged in, and then migrated to a logged-in user profile at a later time.

The major difference between Profile and Session objects are

1. Profile object is persistent whereas Session object is non-persistant.

2. Profile object uses the provider model to store information whereas Session object uses the In Proc, Out Of Process or SQL Server Mode to store information.

3. Profile object is strongly typed whereas Session object is not strongly typed.

The similarity between them is that Each user will automatically have a profile of his own similar to Sessions where each user will have his own Session State.

A user's profile is a collection of properties that define information you want to store for your web site's users. The user's profile is defined using a simple XML syntax in a configuration file (machine.config and/or web.config). Within your page, you reference a user's profile information with the Profile property. ASP.NET reads the schema defined in configuration, and automatically generates a class that is accessible from the Profile property on a page. You access properties on the Profile just as you would access properties on any other class.

Although the most common use of the Profile feature is storing data for authenticated users, the Profile feature also supports storing information for anonymous users. Storing profile information for anonymous users depends on the Anonymous Identification feature. The Profile and Anonymous Identification features work together to enable the use of the Profile property for anonymous users. The samples included in the QuickStart demonstrate using the Profile feature with both authenticated and unauthenticated users.

Prior to the start of the page lifecycle, ASP.NET ensures that the Profile is available for use by the page. Similarly, at the end of the ASP.NET page lifecycle, ASP.NET automatically saves the Profile to the underlying data store(s). As with other features such as Membership and Role Manager, the Profile feature has been designed with a provider-based model. Providers abstract the physical data storage for a feature from the classes and business logic exposed by a feature. The Profile feature ships with a provider for Microsoft™ SQL Server. You can create your own custom providers and configure them to work either the Profile feature. Pages that use the Profile feature will continue to work unchanged with your custom providers.

In addition to the Profile property, the Profile feature provides support for administration of profiles (both for authenticated users and anonymous users) with the ProfileManager. Common tasks that you perform with the ProfileManager include:

Searching for statistical information about all profiles, profiles for authenticated users, and profiles for anonymous users

Determine the number of profiles that have not been modified in a given period of time

Deleting individual profiles as well as deleting multiple profiles based on a profile's last modification date

We will examine the ways of Defining / Managing and Deleting Profiles in the Next Article(s).

Cheers and Happy Programming !!!

posted @ Thursday, July 07, 2005 1:54 PM

Print

Comments on this entry:

# re: ASP.NET 2.0 : Tired with Sessions? - Use the new Profile property to store user information.

Left by celio at 2/21/2009 8:32 PM
Gravatar
very good!

# Erowid strattera

Left by Armon at 11/23/2009 6:44 AM
Gravatar
Hi everyone. The nice thing about egotists is that they don't talk about other people. Help me! There is an urgent need for sites: Erowid strattera. I found only this - strattera vs vyvanse. Going in this magazine can be used as a therapy - and one can similarly not become the depression of the population, strattera. Strattera, despite their study and deal to subject calcium, there are acceptable windows to this hypotension of medication. With respect :-), Armon from Sudan.

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345