Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.net mvc user management

In asp.net mvc default application you get he account controller which enable user registration, log in, log out and changing password.

I was wondering is it possible to implement litle more like enabling administrator to delete some user or give some user different roles like in asp.net configuration where you create user, roles and asign roles to users?

I already figured out and extend profile for users, so now they have much more infos and profile picture.

If you have any experience or examples of user management in asp.net mvc.

like image 748
Goran Bralo Avatar asked Jul 01 '11 12:07

Goran Bralo


People also ask

What is user control in ASP.NET MVC?

Introduction. It's common in ASP . NET Web Forms to create user controls that encompass frequently accessed user interface components. WebForms user controls can be created which allow setting of properties, customization, and placement on any aspx web form for display of content.

Is MVC better than razor pages?

Razor Page is similar to the HTML page but it loads data easily. A Razor Page is almost the same as ASP.NET MVC's view component. It has basically the syntax and functionality same as MVC. The basic difference between Razor pages and MVC is that the model and controller code is also added within the Razor Page itself.

How can create role based authentication in ASP.NET MVC?

Open Visual Studio 2015 or an editor of your choice and create a new project. Choose "web application" project and give an appropriate name to your project. Select "empty" template, check on the MVC box, and click OK. Right-click on the Models folder and add a database model.


1 Answers

Although a bit outdated, this project maybe can give you a few hints on how to implement membership administration in ASP.NET MVC:

Asp.Net MVC Membership Starter Kit

Quote

What is the Asp.Net MVC Membership Starter Kit?

The starter kit currently consists of two things:

  1. A sample website containing the controllers, models, and views needed to administer users & roles.
  2. A library that provides testable interfaces for administering users & roles and concrete implementations of those interfaces that wrap the built-in Asp.Net Membership & Roles providers.

Out of the box, the starter kit gives you the following features:

  • List of Users
  • List of Roles
  • User Account Info
  • Change Email Address
  • Change a User's Roles

Update

For restricting certain operations to specific user roles, you can create these roles using the project I mentioned earlier, and then decorate your own application's controllers and/or actions with an Authorize attribute, referencing the desired roles:

[Authorize(Roles = "Administrator, HR")]
public ActionResult DeleteUser(int UserId)
{
    // do something
}

This would prevent users that are not Administrator or HR to delete users.

like image 103
Daniel Liuzzi Avatar answered Nov 15 '22 07:11

Daniel Liuzzi