Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1020
  • Last Modified:

Code snippet to implement custom membership provider in ASP.NET MVC

I want to implement a custom membership provider in an MVC app.   I am already using forms authentication and  I have a simple database schema for membership/roles that comprises of two tables as only one user can be in one role.

Here are My table schema is in the code snippet below.

I currently check for a user's role by doing

if (User.userRole.roleName == "admin")////

But want to implement custom membership/roles so I need a code snippet that would implement the provider.   T

UserID           Int
RoleID           Int
Username         varchar(100)
AreaID           int
FirstName        varchar(100)
Surname          varchar(100)
Password         varchar(100)
Email            varchar(100)
CreatedOn        datetime
ModifiedOn       datetime
IsAuthorised     bit

RoleID           int
RoleName         varchar(100)

AreaID           int
AreaName         varchar(100)

Open in new window

  • 3
  • 2
2 Solutions
ToString1Author Commented:
OK thanks

I am using linq to sql so would want something in that.  I do not want to write stored procedures
ToString1Author Commented:
OK that is interesting

In my MVC app I am implementing forms authentication and nothing else

So with this post

Can I implement role based authentication, ie,  I want to partition off admin and superadmin parts of the app
In fact if you import the right libraries, you can use the same functionality as you used for Web Forms. Personally, I make the same functionality.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now