利用微软的登录中的控件,当注册的时候,我会在aspnet_profile表中,添加用户的伞个个人信息:Address,Telephon,Balance
我在web.config里边设置的如下:
code=C#]<profile>
<properties>
<add name="Address" allowAnonymous="true"/>
<add name="Telephon" allowAnonymous="true"/>
<add name="Balance" allowAnonymous="true"/>
</properties>
</profile>[/code]
如果设置成匿名用户不允许使用,我无法在用户注册的时候,把用户的个人信息添加到aspnet_profile表里边。
如果设置成为匿名用户允许使用,注册的时候添加的三个字段的UserId为匿名用户UserId,而非注册用户的USerId
后来没办法我又添加了一张表和存储过程:UserInformation,AddUserInformation,存放用户信息。但是当我完成添加用户信息的时候,却发现[UserInformation]这张表中为空。非常头大。
protected void AddUserInfo() {
SqlConnection cn = new SqlConnection("....");
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandText = "AddUserInformation";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserName", CreateUserWizard1.UserName.ToString());
cmd.Parameters.AddWithValue("@Balance",0);
cmd.Parameters.AddWithValue("@Addre",null);
cmd.Parameters.AddWithValue("@Telephon",null);
try
{
cn.Open();
cmd.ExecuteNonQuery();
}
catch (Exception e)
{
string s = e.Message;
Response.Write("<scrpit>alert('" + s + "')</scrpit>");
}
finally {
if (cn.State == ConnectionState.Open)
{
cn.Close();
}
}
}
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
Roles.AddUserToRole(CreateUserWizard1.UserName.ToString(), "User");
AddUserInfo();
Response.Redirect("~/Anonymity/Login.aspx");
}
请问,如何试用aspnet_profile表,扩展用户信息,使得用户注册的时候,顺便把扩展内容加载到aspnet_profile表中去?
------最佳解决方案--------------------------------------------------------