What is the best way to implement Users & Roles Au

2019-07-31 19:56发布

问题:

I am looking to see what is the best way to implement asp.net membership in an MVC 3 project. One thing to note is that I have a separate users table and would like to still use this. So can I link my users table to the asp.net memberships table?

Cheers, Noel.

回答1:

Description

You can implement your own MembershipProvider. Then you have full control about how authentification works and wich database / tables are relevant.

I think you dont need the default asp.net membership database.

More Information

Create a Custom Membership Provider?



回答2:

You can create an additional field (unique identified type) on your custom table and link it to the membership users table.

create new user, if succeed then get id for the newly created user and insert it to your custom table.

MembershipUser mUser= Membership.GetUser(username);
Guid myId =  (Guid)mUser.ProviderUserKey;

...Insert my/id to your custom table.