How do I setup a Membership Provider in my existing database using ASP.NET MVC?
Asked Answered
M

3

28

For some reason, the idea of setting up Membership in ASP.NET MVC seems really confusing.

Can anyone provide some clear steps to setup the requisite tables, controllers, classes, etc needed to have a working Membership provider?

I know that the Demo that MVC ships with has an Accounts controller. However, should I be using this in my own project? What do I need to get my existing database ready if so? If not, how do I learn what I need to do to implement a membership provider?

Mchugh answered 13/7, 2009 at 20:6 Comment(1)
+1 the whole implementation of the membership provider is confusingWalleye
B
19

Check out this step by step blog on how to set up Membership provider in your asp.net mvc project. The sdk tool you need to get your database ready is aspnet_regsql.exe, you don't need to create a separate database to do that ( a lot of people think they have to provide a separate aspnet.db), you can run the command on your existing database, and it will create the tables, views, and stored procedures to handle the membership provider for you.

However, should I be using this in my own project? What do I need to get my existing database ready if so? If not, how do I learn what I need to do to implement a membership provider?

The benefit to use the default provider (SqlMembership provider) is to save yourself a lot of time. It involves a lot of work to design a complete membership and role provider.

Edit [2014-06-19] Asp.Net Identity Framework is Microsoft new recommendation to manage user sand permissions.

Burnout answered 13/7, 2009 at 20:12 Comment(3)
I agree totally. The provided SqlMembership is so easy to implement and covers the majority of the cases necessary for a login system.Ellamaeellan
So, if I follow what is used above, will I also use the "Account" controller that comes with the MVC template?Mchugh
Yes, why not if it's given to you free. Never reinvent the wheel except you are sure you can make the wheel better.Burnout
E
2

Check out this link: https://github.com/TroyGoode/MembershipStarterKit

Most of the work is already done for you. Just download the sample project and run the aspnet_regsql.exe against your database.

Enlighten answered 10/3, 2011 at 20:21 Comment(0)
K
1

check out my answer in this post;

membership

If you want to keep the membership provider that .Net creates for you then you can copy all the tables etc to another sql database and point the provider at it via the config file.

Post a comment if you need more than this.

Kane answered 13/7, 2009 at 22:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.