C # ASP.Net WebForm Membership Additional User Information (Profile)

Iโ€™m learning how to use ASP.net membership when a user logs in, they just create a username and password, however I want to create a page on my site called โ€œprofileโ€ where they can fill in additional data such as first name, last name, date of birth ect. However, I do not see where I can place this in the asp.net membership database. However, in the asp.net_profile table, I'm not sure how this works.

Can someone explain how I can do this?

+4
source share
3 answers

You should consider the built-in membership element as a black box - expanding a stock membership scheme is a pretty bad idea overall.

The profiles are pretty ugly to be honest - kind, if you are comfortable with storing different settings, but I would really like to store the data that I at one point cared about extracting. The main problem is that it stores material in an opaque serialized field, so it is difficult to extract data. Overhead can be frustrating because they will deserialize this material for every request, so if you have an extensive profile, it can become expensive. And in most cases, you should not extract unnecessary profile information for each request.

Regarding usage, I would start from the MSDN page . Also note that MVC has additional problems - it is not directly connected to this stack, although it can still be used.

All that said, you probably want to create your own member profile table. You will probably double some data with built-in membership bits, but that's fine. You need to set up this table with some kind of membership attitude - I prefer using the owner identifier structure rather than directly linking it to accounts, as this makes things much more flexible. For example, it allows users to have multiple profiles, if necessary.

+4
source

You may have to first create a MemberhipUser using Memberhip.CreateUser, grab the newly created user ID and then insert additional profile information in a separate table (e.g. ExtendedUserInfo, etc.) and associate this with the aspnet_Users table with the forein key.

+4
source

So, as you have already set up the membership and roles section, you do the same with the profile section. But here you can provide properties such as:

<profile defaultProvider="AspNetSqlProfileProvider"> <properties> <add name="Name" /> <add name="Weight" type="System.Int32" /> <add name="BirthDate" type="System.DateTime" /> </properties> </profile> 

In your code, you can call Profile.Name and assign a value, the ASP.Membership structure controls the storage of values.

Additional information on how to use it is at http://msdn.microsoft.com/en-us/library/d8b58y5d(v=vs.100).aspx , but it is a bit outdated, but shows the basics.

+2
source

Source: https://habr.com/ru/post/1433144/


All Articles