Question


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.

Was it helpful?

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?

OTHER TIPS

Personally, I like to use the built-in membership provider (have yet to look at the SimpleMembership) for the registration, login and roles.

I then simply create my own member tables that I tie together with the membership User table.

This simple approach prevents me from having to create my own membership provider, and I am free to define the member table the way I want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top