How to implement ASP.NET membership provider in my domain model

后端 未结 4 1848
花落未央
花落未央 2020-12-23 18:01

In a website, I need to integrate membership and authentication. So I want to use the functionality of ASP.NET Membership, but I have other custom stuff, that a \"user\" has

4条回答
  •  难免孤独
    2020-12-23 18:08

    I've thought about it and there are 2 ways that seem appropriate (of course there are more ways to make it work).

    Custom Membership Provider

    You change the membership provider to use your own and use your User object to store all the information.

    The problem with this one is that it involves a lot of re-implementation of things that are already well handled by Asp.Net. The good thing is that you have a single User object with all the details.

    Link from a Membership User to your User

    With this method, you would use the original Membership provider to handle the user name and password, but you link your own User object with this one with something like the user name by using a service for example.

    It's really easy to set up, you just need to create a service that would be used like this:

    string userName = "Jon Skeet";
    User user = new UserManagementServices().GetUserByUserName(userName);
    

提交回复
热议问题