[Webinar] Streamline your web hosting managementRegister Today

x
  • 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



USER
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


ROLES
RoleID           int
RoleName         varchar(100)

AREA
AreaID           int
AreaName         varchar(100)

Open in new window

0
ToString1
Asked:
ToString1
  • 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
0
 
roxviperCommented:
0
 
ToString1Author Commented:
OK that is interesting

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

So with this post

http://mikehadlow.blogspot.com/2008/03/forms-authentication-with-mvc-framework.html

Can I implement role based authentication, ie,  I want to partition off admin and superadmin parts of the app
0
 
roxviperCommented:
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.
0

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