简体   繁体   中英

Role Based Asp.net MVC App

I need to built a simple asp.net mvc app. app requirement is

1) on loading login page will open that ask to login either by general user or administrator

2) No Sign up or register page . Only admin can login and create users.

3) If admin is logged in . he can create/delete other users and create roles as well.

4) Other users can login and perform certain tasks eg data listing and adding/deleting records.

5) I already have the ms sql server database i want to link to this database for user/role records.

Please give me suggestions how can i achieve this?

You can start with a default ASP.NET MVC project which provides some sort of membership - ASP.NET Membership/Identity. And then remove certain functionality to disable users from registering a new account. Then you can develop your own way of creating an account.

You can probably reuse some of the code which you removed earlier to create an account give it permissions etc.

** This type of open ended question are normally down voted. You need to be more specific with the problem you are facing and share your analysis . **

Anyways here is some tip, You can use SimpleMembershipProvider , it provides all you need for users and role.

If you create a new MVC 4 application in Visual Studio, you will get a precooked working form authentication enabled internet application.

Go through the code in AccountController , you will find most of the functionality already implemented with the help of WebSecurity wrapper class. As Adrian suggested, remove registration part.

You can create default role (admin) and users through SQL script or by using Seed method.

Once you reach that level, you may have some specific question, please share and we will be happy to help.

You can refer following two links to start with:

http://www.codeguru.com/csharp/.net/net_asp/mvc/using-simplemembership-in-asp.net-mvc-4.htm

http://www.codeproject.com/Articles/689801/Understanding-and-Using-Simple-Membership-Provider

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM