Build membership
1, Create a new ASPNETDB database: output Aspnet_regsql at the vs2010 command prompt
2. Under the 3.5 version of the new ASP.NET website, modify the configuration file and add a string
3: Set the <profile> configuration section, and often set the three parts
- <profile> own properties
- Subsection <properties> Properties Settings
- subsection <providers> attribute settings
Note: allowAnonymous is used in conjunction with anonymous personalization settings. You can now use it without writing a string collection. You can use it later or ignore it.
ASP.NET configures users to log in on the website management tool page
small example
1: Login.aspx interface
Drag Login directly in the login control column
2: Welcome.aspx interface
3:Addprofile.aspx
Add event for save settings
protected void Button1_Click(object sender, EventArgs e) { if (!Profile.IsAnonymous) { Profile.usename = TextBox1.Text; Profile.userpwd = TextBox2.Text; Profile.birthday = Calendar1.SelectedDate; Response.Redirect("Default.aspx"); } else { Profile.usename = TextBox1.Text; Profile.userpwd = TextBox2.Text; Response.Redirect("Default.aspx"); } }
4: Default.aspx page is used to display content
protected void Page_Load(object sender, EventArgs e) { Response.Write("昵称:" + Profile.usename + "<br/>密码:" + Profile.userpwd + "<br/>生日:"+Profile.birthday.ToLongDateString()); }
5: Anonymous Personalization
To enable anonymous personalization, you need to enable the configuration section anonymousIdentification and set the attribute enable to true.
The allowAnonymous attribute and <anonymousIdentification enabled="true"/> must be added together