开发者

asp.net web application project template Membership

I would like to use the built-in membership / authentication system that is included by default in Visual Studio when creating a new asp.net web application.

My question is I have a user table... UserID, FirstName, LastName, etc. with company info that I want to use. How do I go about linking this table to the new registration 开发者_如何学CI created?

Suppose I created a new registration. Now where is the login and password data being stored?

Can anyone point me in the right direction?


This tutorial can be very helpful at the beginning: Creating the Membership Schema in SQL Server.

If you have basically only user profile information in your existing company database, may be you'll need to consider creating a custom Profile Provider. Be aware that doing it while using the Web Application Project has its perculiarities.

If you have also other information in your database linked to user by foreing keys, may be you'll be interested in this discussion on how to use it with Membership.


The membership info is stored in a SQL database ASPNETDB.MDF by default. You can find this file in your App_data folder.

If you want to change the way membership behaves, and which database and tables it uses I would recommend creating a custom membership provider.

See http://msdn.microsoft.com/en-us/library/aa479048.aspx or google asp.net custom membership provider:

If you just want the existing membership provider to use a different database you can run the aspnet_regsql utility:

See http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx

This example of a custom membership provider that uses entity framework codefirst helped me to get started:

http://codefirstmembership.codeplex.com/


My humble suggestion is that you simply create a seperate table and relate it to your user table with a realtionship. So there is no change about where the login and password are stored.

This article might help you : http://www.asp.net/security/tutorials/storing-additional-user-information-cs . Take a look at it.

Additional Articles:

https://web.archive.org/web/20211020111657/https://www.4guysfromrolla.com/articles/101106-1.aspx

https://web.archive.org/web/20211020114106/https://www.4guysfromrolla.com/articles/110310-1.aspx

Hope this helps.


Thanks all for your replies, you all gave me some insight to help me figure out my problem. I decided to take an easier route.

This is what I came up with. In Register.aspx.cs:

protected void RegisterUser_CreatedUser(object sender, EventArgs e)
{

    TextBox txtFirstName = (TextBox)(RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txtFirstName "));
    string firstName= txtFirstName.Text;

    ... Insert new fields  in database ....

}

And added the controls in the CreateUserWizard control. Pretty simple solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜