首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

ASP.NET 登录控件以及aspnet_profile的几个小问题

2012-12-28 
ASP.NET登录控件以及aspnet_profile的几个问题利用微软的登录中的控件,当注册的时候,我会在aspnet_profile

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");
    }


请问,如何试用aspnet_profile表,扩展用户信息,使得用户注册的时候,顺便把扩展内容加载到aspnet_profile表中去?
------最佳解决方案--------------------


没法加。加表,与主键相连调用
[其他解释]
学习一下 
[其他解释]
看帖回复是一种美德。。。
[其他解释]
拓展内容

你要给aspnet_profile加字段吗?

自己写个登陆 不是很难。。。
[其他解释]
可以重写一下:
create database Accounts on (name = 'Accounts_dat',filename = 'F:\Database\Accounts.mdf ');
--drop database Accounts
use Accounts
create table Accounts.dbo.Applications
(
ApplicationName nvarchar(256) not null,
LoweredApplicationName nvarchar(256) not null,
ApplicationId uniqueidentifier not null primary key,
Description nvarchar(256),
);
create table Accounts.dbo.Users
(
ApplicationId uniqueidentifier not null foreign key references Accounts.dbo.Applications(ApplicationId),
UserId uniqueidentifier not null primary key,
UserName nvarchar(256) not null,
LoweredUserName nvarchar(256) not null,
MobileAlias nvarchar(16) null,
IsAnonymous bit not null,
LastActivityDate datetime not null
);
create table Roles
(
ApplicationId uniqueidentifier  not null foreign key references Accounts.dbo.Applications(ApplicationId),
RoleId uniqueidentifier not null primary key,
RoleName nvarchar(256)  not null,
LoweredRoleName nvarchar(256)  not null,
Description nvarchar(256)
);
create table Accounts.dbo.UsersInRoles
(
UserId uniqueidentifier not null foreign key references Accounts.dbo.Users(UserId),
RoleId uniqueidentifier not null foreign key references Accounts.dbo.Roles(RoleId),
primary key(UserId,RoleId),
);
create table Accounts.dbo.Profiles
(
UserId uniqueidentifier not null primary key,
PropertyNames ntext not null,
PropertyValuesString ntext not null,
PropertyValuesBinary image not null,
LastUpdatedDate datetime not null,
constraint Krf foreign key(UserId) references Accounts.dbo.Users(UserId)
)
create table Accounts.dbo.Membership
(
ApplicationId uniqueidentifier not null foreign key references Accounts.dbo.Applications(ApplicationId),
UserId uniqueidentifier not null primary key,
Pwd nvarchar(128) not null,
PwdFormat int not null,
PwdSalt nvarchar(128) not null,
MobilePIN nvarchar(16),
Email nvarchar(256),
LoweredEmail nvarchar(256),
PwdQuestion nvarchar(256),
PwdAnswer nvarchar(128),
IsApproved bit not null,
IsLockedOut bit not null,
CreateDate datetime not null,
LastLoginDate datetime not null,
LastPwdChangedDate datetime not null,
LastLockoutDate datetime not null,
FailedPwdAttemptCount int not null,
FailedPwdAttemptWinStart datetime not null,
FailedPwdAnswerAttemptCount int not null,
FailedPwdAnswerAttemptWinStart datetime not null,
Comment ntext,


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
)

热点排行