Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# ASP.Net WebForm Membership Extra User Details (Profile)

Tags:

c#

asp.net

I'm learning how to use the ASP.net membership, when a user registers they just create a username and password, however i want to create a page on my website called "profile" where they can fill in extra details such as firstname, lastname, date of birth ect. However i don't see where i can place this in the asp.net membership database. Theres an asp.net_profile table however i'm not sure how this works.

Could someone please explain how i can do this?

like image 495
user1638362 Avatar asked Dec 27 '22 18:12

user1638362


2 Answers

You should treat the built-in membership stuff as a black box -- extending the stock membership schema is a pretty bad idea in general.

The profiles is pretty ugly to be honest -- kind if handy for storing miscellaneous settings but I would hate to store data I cared about extracting at some point. The main issue is it stores stuff in an an opaque serialized field so it is hard to extract your data. Overhead can be nasty as it will deserialize this stuff on every request, so if you have an extensive profile it can get expensive. And it isn't worth pulling out someone's extra profile info every request in most cases.

As for usage, I'd start with the MSDN page. Also note that there are additional challenges in MVC -- it is not wired into that stack as directly, though one can still make use of it.

All that said, you probably want to build out your own member profile table of some sort here. You probably will double-book some data with the built-in membership bits but that is OK. You will want to setup this table with some sort of relationship to the membership -- I prefer using an "owner account id" structure rather than keying it directly to accounts as that makes things much more flexible. For example, it lets users have multiple profiles if that becomes necessary.

like image 153
Wyatt Barnett Avatar answered Dec 29 '22 09:12

Wyatt Barnett


You will probably have to create MembershipUser first by using Membership.CreateUser, grab the newly created user's id and then insert his extra profile information in seperate table (like ExtendedUserInfo etc) and link that with aspnet_Users table with forein key.

like image 21
Agent007 Avatar answered Dec 29 '22 10:12

Agent007