Search code examples
c#asp.net-mvcmembership

How do I do a registration in ASP.NET MVC?



I'm relatively new to ASP.NET MVC, but I already did C# for a while and I already took the MVC basic course. What I'm stuck with is the "ASP.NET Membership".

For my website, I need a registration (with email, password, and some cstom fields), a login, "roles" (user, admin. moderator, etc...), "settings" (change password, etc ...) and cca. 40 custom fields (like date of birth, favorite color, car type, etc ...) connected to the user.

How should I make it in MVC?

I have found the SimpleMembership, but I don't need most of it's features, and the features I need are missing.


Solution

  • My time to shine!

    I would recommend using the Entity Framework, because reasons. It makes DB interactions very simple and readable.

    you can write your own membership provider in MVC, which like you said you wont need most of the features, so you dont need to implement them. This dude implemented it all here ->

    http://www.brianlegg.com/post/2011/05/09/Implementing-your-own-RoleProvider-and-MembershipProvider-in-MVC-3.aspx

    He tells which ones to focus on, and shows roles and authorization.

    Essentially you will map a User model to your User table using the entity framework, then use that user model when the person is registering. You can even use validation attributes, as seen here->

    http://www.asp.net/mvc/tutorials/older-versions/models-(data)/validation-with-the-data-annotation-validators-cs

    What other questions may I answer to help you on your journey today my good sir?