ASP.NET 登录控件以及aspnet_profile的几个问题
利用微软的登录中的控件,当注册的时候,我会在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");
}
constraint Fk foreign key(UserId) references Accounts.dbo.Users(UserId)
)
create table Accounts.dbo.Paths
(
ApplicationId uniqueidentifier not null foreign key references Accounts.dbo.Applications(ApplicationId),
PathId uniqueidentifier not null primary key,
Path nvarchar(256) not null,
LoweredPath nvarchar(256) not null,
)
create table Accounts.dbo.PersonalizationAllUsers
(
PathId uniqueidentifier not null primary key,
PageSettings image not null,
LastUpdatedDate datetime not null,
constraint PFk foreign key(PathId) references Accounts.dbo.Paths(PathId)
)
create table Accounts.dbo.PersonalizationPerUser
(
Id uniqueidentifier not null primary key,
PathId uniqueidentifier foreign key references Accounts.dbo.Paths(PathId),
UserId uniqueidentifier foreign key references Accounts.dbo.Users(UserId),
PageSettings image not null,
LastUpdatedDate datetime not null
)