zoukankan      html  css  js  c++  java
  • 购物车的实现(一)——认识Profile

    源代码:13033480群共享

    那是在一个月黑风高的夜晚,寒风刺骨,伸手不见五指,我......

    我是在温馨明亮的家中,坐在电脑旁的,突然,发现了一段代码,在这个代码里,Profile被用来做了站点计数器......

    【操作步骤】

    一、新建网站Web

    二、添加Web配置文件Web.config,在Web.config中的<system.web>节中添加配置

    <authenticationmode="Forms" />

    <anonymousIdentificationenabled="true"/>

    <profile>

      <properties>

        <addname="Counts"type="Int32"defaultValue="0"allowAnonymous="true"/>

      </properties>

    </profile>

    三、窗体文件Default.aspx添加3个标签控件,简单布局如下:

    <div>

       用户名:<asp:LabelID="lblUserName"runat="server"></asp:Label><br/>

       是否匿名:<asp:LabelID="lblIsAnonymous"runat="server"></asp:Label><br/>

       站点计数:<asp:LabelID="lblCounts"runat="server"></asp:Label>

    </div>

    四、Default.aspx.cs中的代码如下:

    protected void Page_Load(object sender, EventArgs e)

    {

        lblUserName.Text = Profile.UserName;

        lblIsAnonymous.Text = Profile.IsAnonymous.ToString();

        Profile.Counts++;

        lblCounts.Text = Profile.Counts.ToString();

    }

    五、运行,并不断刷新,查看结果。

    【技术要点】

    一、Profile,是.NET Framework提供了一种不同于cookie和Session的存储用户信息的类,通常在电子商务系统中实现购物车时使用。

    二、Profile把用户通常把用户信息存储在App_Date文件夹中自动生成的数据库ASPNETDB.MDF中;

    三、匿名用户使用Profile,需要在Web.config文件中设置Forms登录方式,并开启匿名认证功能;

    四、简单的应用,Profile的属性,需要在Web.config中设置,如果匿名用户需要修改属性值,还需要设置allowAnonymous="true"

    版权所有©2012,西园电脑工作室.欢迎转载,转载请注明出处.更多文章请参阅博客http://blog.csdn.com/yousuosi

  • 相关阅读:
    DevExpress v17.2新版亮点—ASP.NET篇(一)
    使用MyEclipse将HTML5移动项目迁移到PhoneGap(一)
    DevExpress v17.2新版亮点—WPF篇(七)
    什么是SpringBoot?
    application.yml中常用参数设置
    什么是MyBatis?
    什么是Spring?
    项目访问路径去掉默认的项目名
    StringUtils常用方法介绍
    Spring学习----自动装配@Resource、@Autowired、@Qualifier
  • 原文地址:https://www.cnblogs.com/WestGarden/p/3138357.html
Copyright © 2011-2022 走看看