在Global.asax文件中,增加一个方法:
  protected void Profile_MigrateAnonymous(Object s, ProfileMigrateEventArgs e)
    {
        ProfileCommon anonProfile = Profile.GetProfile(e.AnonymousID);
       
        //迁移Profile用户名
        //Profile.userName = anonProfile.userName;
       
        //迁移购物车
        //Profile.ShoppingCart = anonProfile.ShoppingCart;
       
        IEnumerator ie = anonProfile.ShoppingCart.CartItems.GetEnumerator();
        while (ie.MoveNext())
        {
            Profile.ShoppingCart.AddCartItem((CartItem)ie.Current);
        }             
      
        //清除匿名COOKIE,不然每次请求页面都执行此事件
        AnonymousIdentificationModule.ClearAnonymousIdentifier();
        // Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(-1);
       
        //匿名COOKIE标识已重置,下次匿名访问将创建新的profile数据条,原来的匿名profile数据条已无意义
        ProfileManager.DeleteProfile(e.AnonymousID);      
    }