会员和放大器;简介帮助需要使用asp.net的CreateUserWizard和登录控制 [英] membership & profile help needed using createuserwizard and login control in asp.net
问题描述
我工作的一个项目,我得到了一个任务来创建一个用户(使用CreateUserWizard控件)。我必须保存用户在特定的表中的SQL Server数据库。
I am working on a project where I got a task to create a user (using the CreateUserWizard control). I have to save the user in a specific table in the SQL Server database.
另外创建一个登陆(使用Login控件)和登录通过身份验证后,应持个人资料信息。
Also create a login (using the Login control) and after the login is authenticated it should hold the profile information.
到目前为止,我已经创建了CustomProfile的inherites ProfileBase。还创造了3 aspx页面。
So far, I have created CustomProfile that inherites the ProfileBase. Also have created 3 aspx pages.
- 的Login.aspx
- CreateUser.aspx
- 的Default.aspx
我CustomProfile如下所示:
My CustomProfile looks like the following:
public class UserProfile : ProfileBase
{
static public UserProfile CurrentUser
{
get
{
return (UserProfile)(ProfileBase.Create(Membership.GetUser().UserName));
}
}
public string FirstName
{
get { return (string)base["FirstName"]; }
set { base["FirstName"] = value; Save(); }
}
public string LastName
{
get { return (string)base["LastName"]; }
set { base["LastName"] = value; Save(); }
}
public DateTime DateOfBirth
{
get { return (DateTime)base["DateOfBirth"]; }
set { base["DateOfBirth"] = value; Save(); }
}
public ContactInfo Contact
{
get { return (ContactInfo)base["Contact"]; }
set { base["Contact"] = value; Save(); }
}
}
我用 aspnet_regsql.exe的
,它创造了SQL Server和存储这些表中的数据多个表和工作正常。我想将信息保存到我的表如。 tblUserInfo
。我应该如何进行?我查了多个论坛,但没有运气。
I have used aspnet_regsql.exe
and it created multiple tables in the sql server and storing the data in those tables and is working fine. I would like to save the information into my table eg. tblUserInfo
. How should I proceed? I checked multiple forums but no luck.
任何帮助很多AP preciated。
Any help is much appreciated.
推荐答案
所有aspnet_regsql.exe的首先是过时的。你可能要考虑使用<一个href=\"http://www.hanselman.com/blog/IntroducingSystemWebProvidersASPNETUniversalProvidersForSessionMembershipRolesAndUserProfileOnSQLCompactAndSQLAzure.aspx\"相对=nofollow> ASP.Net通用提供。
First of all aspnet_regsql.exe is outdated. You might want to consider using ASP.Net Universal Providers.
我假设你的问题的的将信息保存到我的表如。 tblUserInfo 的
I assume your question is save the information into my table eg. tblUserInfo
而不是使用的CreateUserWizard的,你可以收集用户信息,并自行保存。
Instead of using CreateUserWizard, you can collect the user information and save it by yourself.
1。创建tblUserInfo表(替代解决方案ASP.Net配置文件)
2。插入的UserInfo成tblUserInfo创建用户后
<asp:TextBox ID="UsernameTextBox" runat="Server" />
<asp:TextBox ID="EmailTextBox" runat="Server" />
<asp:TextBox ID="PasswordTextBox" runat="Server" />
<asp:TextBox ID="PasswordQuestionTextBox" runat="Server" />
<asp:TextBox ID="PasswordAnswerTextBox" runat="Server" />
<asp:TextBox ID="FirstNameTextBox" runat="Server" />
<asp:TextBox ID="LastNameTextBox" runat="Server" />
string username = UsernameTextBox;
string password = PasswordTextBox.text;
string email = EmailTextBox.text;
string passwordQuestion = PasswordQuestionTextBox.text;
string passwordAnswer = PasswordAnswerTextBox.text;
bool isApproved = true;
MembershipCreateStatus status;
MembershipUser membershipUser = System.Web.Security.Membership.CreateUser(
username, password, email, passwordQuestion, passwordAnswer, isApproved, out status);
if (status != MembershipCreateStatus.Success)
throw new Exception(status.ToString());
// Save the rest of the user info to tblUserInfo with userId
Guid userId = (Guid)membershipUser.ProviderUserKey;
<一个href=\"http://stackoverflow.com/questions/10114451/can-you-wrap-the-roleprincipal-in-a-custom-iprincipal-object/10116939#10116939\">3.如何使的UserInfo可登录用户?
这篇关于会员和放大器;简介帮助需要使用asp.net的CreateUserWizard和登录控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!