Anonymous Personalization

It is common to allow your users to personalize your site before identifying themselves. A classic example of this is Amazon.com , which lets you add books to your shopping cart before you log in (you only need to log in when you are ready to purchase what is in your cart).

ASP.NET 2.0 supports personalization for anonymous users as well as the ability later to link anonymous personalized data with a specific user's. Once that user logs in, you don't want to lose what was in the user's cart.

To enable anonymous personalization, you must update your Web.config file adding:

               
    <anonymousIdentification enabled="true" />

Add the attribute-value pair allowAnonymous="true" to the CHOSENBOOKS element of Web.config, as shown in Example 12-17.

Example 12-17. Modified Web.config for anonymous access

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
   <connectionStrings>
      <remove name="LocalSqlServer"/>
      <add name="LocalSqlServer" connectionString="data source=.\SqlExpress;Integrated
Security=SSPI;Initial Catalog=aspnetdb"/>
   </connectionStrings>
   <system.web>
      <anonymousIdentification enabled="true" /> <roleManager enabled="true" /> <authentication mode="Forms"/> <membership defaultProvider="AspNetSqlMembershipProvider"/> <compilation debug="true"/> <profile enabled="True" defaultProvider="AspNetSqlProfileProvider"> <properties> <add name="lastName" /> <add name="firstName" /> <add name="phoneNumber" /> <add name="birthDate" type="System.DateTime"/> ...

Get Programming Visual Basic 2005 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.