Reputation: 317
I'm new in ASP.NET MVC. I've switched to it from PHP.
In PHP, when i was creating a page that manage users, i often created the tables Users and Profiles and store the data in them. In ASP.NET, there are the Membership and Profile Providers.
So, my question is, what is the best way to manage users in ASP.NET MVC? Should I create custom tables and logic like in PHP or should I create Custom Providers?
I know, there are many similiar topics about this problem. However, none of them is exactly what I need.
Thanks in advance, Mike.
Upvotes: 7
Views: 8842
Reputation: 28701
I agree with Oscar and frenchie - don't reinvent the wheel. The ASP.NET membership providers should provide you with a good start. However, if you're a fan of TDD, you may find you'll need to encapsulate the membership provider implementation inside a class you can control so that you can deal with mocking. The membership provider contract is pretty huge and tightly coupled, and I've found out through experience that you end up only using 30-40% of that beast. Create your own contract and use it to interact with the membership provider. You'll thank yourself later.
Good luck!
Upvotes: 2
Reputation: 54628
Probably should say there is no best way. Best is ambiguous.
I'd say there are three general types of ways to do users and roles with a SQL server (I mention this because you mentioned tables).
First: Use the built-in ASP.NET (webforms/mvc agnostic) SqlMembership Provider. It contains most of the features people need to manage users. This is most likely to be the fastest to implement, but the least extensible. This would be highly recommended.
Second: Build your own [Membership Provider], to follow the Membership provider pattern but introduce your own logic from the SQL to the Application. Building your own provide can be quite a lengthy process, but you still get all the nice features, and can be used in other projects because it is it's own provider and not tied to the application.
Third: Build your own logic from complete scratch. I would not recommend this unless you plan to build it like an independent application.
Upvotes: 3
Reputation: 4169
use ASP.Net Memebership do not recreate the wheel,
http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-7
Upvotes: 3