What is the best way to implement Users & Roles Authorization and Authentication in MVC 3

那年仲夏 提交于 2019-12-11 10:34:03

问题


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.



来源:https://stackoverflow.com/questions/8339910/what-is-the-best-way-to-implement-users-roles-authorization-and-authentication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!