ASP.NET: Custom MembershipProvider with a custom user table

Posted by blahblah on Stack Overflow See other posts from Stack Overflow or by blahblah
Published on 2010-04-21T14:02:47Z Indexed on 2010/04/21 14:43 UTC
Read the original article Hit count: 394

I've recently started tinkering with ASP.NET MVC, but this question should apply to classic ASP.NET as well. For what it's worth, I don't know very much about forms authentication and membership providers either.

I'm trying to write my own MembershipProvider which will be connected to my own custom user table in my database. My user table contains all of the basic user information such as usernames, passwords, password salts, e-mail addresses and so on, but also information such as first name, last name and country of residence.

As far as I understand, the standard way of doing this in ASP.NET is to create a user table without the extra information and then a "profile" table with the extra information. However, this doesn't sound very good to me, because whenever I need to access that extra information I would have to make one extra database query to get it.

I read in the book "Pro ASP.NET 3.5 in C# 2008" that having a separate table for the profiles is not a very good idea if you need to access the profile table a lot and have many different pages in your website.

Now for the problem at hand... As I said, I'm writing my own custom MembershipProvider subclass and it's going pretty well so far, but now I've come to realize that the CreateUser doesn't allow me to create users in the way I'd like. The method only takes a fixed number of arguments and first name, last name and country of residence are not part of them.

So how would I create an entry for the new user in my custom table without this information at hand in CreateUser of my MembershipProvider?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET