Custom membership or not

后端 未结 5 647
既然无缘
既然无缘 2021-02-04 14:21

I am creating website (football, soccer) in ASP.NET MVC3 and I want have users (with additional information then user in default membership, these are ordinary visitors) and pla

5条回答
  •  独厮守ぢ
    2021-02-04 14:58

    It is very easy to create your own Membership Provider. Just create class derived from MembershipProvider. And implement members which look into DB, for example (or any other data source).

    public class YourMembershipClass: MembershipProvider
    {
        public override bool ValidateUser(string username, string password)
        {
             return YourDataLayer.ValidateUser(username, password);
        }
        public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
        {
            return YourDataLayer.GetSpecificUser(providerUserKey, userIsOnline);
        }
        // Implement the other methods as well
     }
    

    Then add your YourMembershipClass to web.config:

    
      
        
               
      
    
    

提交回复
热议问题