开发者

Profiles in MVC 2 and/or custom user registration

开发者 https://www.devze.com 2023-01-03 21:19 出处:网络
I am working on an MVC 2 application where I need users to add custom fields when they register, for example age, phone number, full name, etc.

I am working on an MVC 2 application where I need users to add custom fields when they register, for example age, phone number, full name, etc.

Investigating I found this blog entry where they use ASP.NET Profiles and customize the CreateUserWizard control. My problem has been that I cannot get this to work since in MVC I have no code-behind and if I had it, probably it wouldn't work since CreateUserWizard uses ViewState.

All I need is what I have said: Ask users to add custom fields when they register (I have already managed to configure Membership, i开发者_运维百科t works well).

I would like to know if there is a way as simple as the one I found to accomplish what I need, whether it uses Profiles or not.

I hope you can help me,

Sam


I found that the easiest way is to use MembershipSystem, but to stay away from ProfileSystem as much as possible.

I use a Usertable that has a column UserID that maps to UniqueID of ProileSystem. You see there is a break in the systems: On the one side there is the profile and on the other side there is my user.

This gets a problem here and there:

  • You create the membership user and profile entry and after it you create the entry in the user table. There is no chance to have a transaction that spans both operations.
  • The user changes his E-Mail. This has to be done for the Mebrshipsystem and for the table user

You could start implementing properties by a custom ProfileProvider. This is easy and you can even use your own User table. But in my case I found out that this was bad: To much of the ProfileSystem creeped into my application. I started by the user table, then I had to think about the address table, the order table....

At the end I saw that there will be a break somewhere, so decided to have it early. Your situation might be different and the ProfileSystem might be helpfull in some situations, but if you start to implement to much of your application inside of the custom profile provider I would think again.

So my suggestion is:

Use MembershipSsytem and ProfileSystem to create an Account and to retrieve an ID for the user. Then Use this ID in your own Backend.


Check out this question; maybe this will point you to the right track. :)

Profile question

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号