Is it possible to create a custom MembershipProvider without the use of the MembershipUser class?
I'd like to use my own User class and to keep things tidy, I'd like to not have to use the MembershipUser class which has a lot of properties I really don't want or need.
No it's not. But you can always write your own abstraction on top of it using a Repository
pattern or similar, and then use your own User
model in the application.
public UserRepository : IUserRepository
{
private MembershipProvider provider;
private UserAdapter userAdapter;
public UserService(MembershipProvider provider, UserAdapter userAdapter)
{
this.provider = provider;
this.userAdapter = userAdapter;
}
public MyUser GetUser(string email)
{
MembershipUser user = provider.GetUser(username, false);
MyUser myUser= userAdapter.Map(user);
return myUser;
}
}