O'Reilly logo

ASP.NET 2.0: A Developer's Notebook by Wei-Meng Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Transfer an Anonymous Profile to an Authenticated Profile

Note

When an anonymous user is authenticated, you need to manually migrate his profile properties.

Although ASP.NET 2.0 lets you maintain information for both authenticated and anonymous users, you need to take special steps to preserve data when you authenticate an anonymous user. For example, an anonymous user may already have items in her shopping cart when she logs in. In this situation, profile data that was saved while she was an anonymous user would normally be lost when the user switches from using a GUID to using a user ID for identification. To migrate the profile of the user, you need to transfer whatever information has been saved as an anonymous profile to the user profile.

How do I do that?

In this lab, you will build on the previous lab, Section 7.3, and learn how you can migrate an anonymous profile to an authenticated profile once a user has been authenticated.

  1. Using the project created in the last lab (C:\ASPNET20\chap07-Profile), add a new Web Form to the Members folder. Name the Web Form Checkout.aspx.

  2. Add a Global.asax file to the project (right-click the project name in Solution Explorer and then select Add New Item...; select Global Application Class).

  3. The Solution Explorer should now look like Figure 7-15.

    Adding the Global.asax file to the project

    Figure 7-16. Adding the Global.asax file to the project

  4. Add the following method to Global.asax. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required