精彩专题推荐:建站之入门课 建站之必修课 建站之关键课 网站价值所在 流量提高专题 css+div 标准 个人网站打造全过程
返回建站学首页
导航:
建站首页 | 网站设计 | 网站开发 | 网站运营 | 网页软件 | 建站指南 | 搜索优化 | 图像处理 | 视频教程 | 书籍教程 | 建站专题
当前位置:首页>网站开发>asp.net教程>正文

ASP.NET2.0学习7--个性化用户配置


来源: 时间:07-03-21 点击: 点击这里收藏本文

        if (time.Year == 1)

        {

            labLastSubmit.Text = "空";

        }

        else

        {

            labLastSubmit.Text = time.ToString();

        }

    }

五、为注册用户实现个性化用户配置

web.config配置

    <connectionStrings>

        <add name="NorthwindConnectionString" connectionString="Data Source=localhost;Initial Catalog=Northwind;Integrated Security=True"

            providerName="System.Data.SqlClient" />

    </connectionStrings>

    <system.web>        

          <profile>

              <properties>

                   <add name="ShoppingCart" type="ShoppingCart" serializeAs="Binary"/>

              </properties>           

          </profile>

          <authorization>

              <deny users="?"/>

          </authorization>

          <authentication mode="Forms">

              <forms loginUrl ="Login.aspx"></forms>

          </authentication>

代码示例:code 13-2

六、匿名用户转化为注册用户的处理

Global.asax中的设置

    void Profile_MigrateAnonymous(Object sender, ProfileMigrateEventArgs pe)

    {

        //获取匿名用户的Profile对象

        ProfileCommon anonProfile = Profile.GetProfile(pe.AnonymousID);

        //如果总价为不为0(说明匿名用户进行了选择),则将匿名用户的Profile存储起来

        if (anonProfile.ShoppingCart.Total  != 0)

        {           

            Profile.ShoppingCart = anonProfile.ShoppingCart;           

        }       

        //删除匿名用户的用户数据(从aspnet_Users表)

        Membership.DeleteUser(pe.AnonymousID);

        //删除匿名用户的Profle数据(从aspnet_Profile表)

        ProfileManager.DeleteProfile(pe.AnonymousID);

        //删除匿名用户标识

        AnonymousIdentificationModule.ClearAnonymousIdentifier();       

}

       示例代码:code 13-3

七、删除个性化信息

删除匿名用户的个性化信息

ProfileManager.DeleteProfile(Context.Request.AnonymousID)

删除注册用户的个性化信息

ProfileManager.DeleteProfile(User.Identity.Name)

9 7 3 1 2 4 8 :

  把此文章收藏到:          
广而告之
文章搜索
  • Google JZxue.Com

关于我们 | 联系我们 | 友情链接 | 网站地图
Copyright © 2005 - 2006 建站学 All rights reserved.