Skip to Content
Beginning ASP.NET 3.5: In C# and VB
book

Beginning ASP.NET 3.5: In C# and VB

by Imar Spaanjaars
March 2008
Intermediate to advanced content levelIntermediate to advanced
766 pages
21h 15m
English
Wrox
Content preview from Beginning ASP.NET 3.5: In C# and VB

16.2. Other Ways of Dealing with Profile

In the final section of this chapter you see two other useful ways of dealing with the Profile feature in ASP.NET. First, you see how to use the Profile for anonymous users followed by a discussion on accessing the profile of a user other than the current user.

16.2.1. Anonymous Identification

The Profile feature is extremely easy to configure, yet very powerful. All you need to do to give logged-in users access to their profiles is create a few elements in web.config and the ASP.NET run time takes care of the rest. But what about anonymous users? What if you wanted to store data for your visitors who haven't signed up for an account or aren't logged in yet? For those users you need to enable anonymous identification. With anonymous identification, ASP.NET creates an anonymous user in the aspnet_Users table for every new visitor to your site. This user then gets a cookie that is linked to the anonymous user account in the database. On every visit, the browser sends the cookie with the request, enabling ASP.NET to associate a user, and thus a Profile, with the user for the current request.

To enable an anonymous profile, you need to do two things: turn on anonymous identification, and modify some or all profile properties to expose them to anonymous users.

Enabling anonymous identification is easy with the following element in web.config, directly under <system.web>:

<anonymousIdentification enabled="true" cookieName="PlanetWroxAnonymous" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning ASP.NET 4: in C# and VB

Beginning ASP.NET 4: in C# and VB

Imar Spaanjaars
Professional ASP.NET 3.5 SP1 Edition: In C# and VB

Professional ASP.NET 3.5 SP1 Edition: In C# and VB

Bill Evjen, Scott Hanselman, Devin Rader

Publisher Resources

ISBN: 9780470187593Purchase book