[Webinar] Streamline your web hosting managementRegister Today

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

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

I want to implement a custom membership provider in an asp.net 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.

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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