Coder Social home page Coder Social logo

iammukeshm / customusermanagement.mvc Goto Github PK

View Code? Open in Web Editor NEW
255.0 10.0 82.0 766 KB

Let’s go in-depth and understand the functionalities you can achieve with the help of Microsoft Identity. We will build a small yet practical implementation of Custom User Management in ASP.NET Core MVC with Identity.

Home Page: https://www.codewithmukesh.com/blog/user-management-in-aspnet-core-mvc/

C# 73.59% HTML 25.58% CSS 0.71% JavaScript 0.12%
identity-management microsoft-identity-manager microsoft-identity asp-net-core asp-net-mvc

customusermanagement.mvc's Introduction

Custom User Management in ASP.NET Core MVC with Identity

In this article, let’s go in-depth and understand the functionalities you can achieve with the help of Microsoft Identity. We will build a small yet practical implementation of Custom User Management in ASP.NET Core MVC with Identity. This will cover most of the practical use cases involved while developing User Management in ASP.NET Core.

Give a Star ⭐️

If you found this Implementation helpful or used it in your Projects, do give it a star. Thanks!

Here are the Topics we will cover

  • Microsoft Identity – Overview
  • Setting up the ASP.NET Core MVC Application
  • Scaffolding the Identity UI
  • Renaming the Default Identity Tables and Updating.
  • Adding Custom Fields to Identity User
  • Extending the Registration Form
  • Allow Login with both Username and Email
  • Adding the Custom User Fields To Profile Settings
  • Adding a Profile Picture
  • Setting a Limit to Change Username
  • User Roles – Overview
  • Seed Default Roles
  • Seed Default Super Admin user
  • Add A Default Role to Newly Registered User
  • Add / View Available Roles
  • Listing Users with Corresponding Roles
  • Addings Users to Roles

Read the entire blog post here - https://www.codewithmukesh.com/blog/user-management-in-aspnet-core-mvc/

Support

Has this Project helped you learn something New? or Helped you at work? Do Consider Supporting.

Buy Me A Coffee

customusermanagement.mvc's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

customusermanagement.mvc's Issues

Support MultipleActiveResultSets=false?

This demo is great and I want to integrate the role manage functions in my project.

In connection string, MultipleActiveResultSets=true is a feature of sqlserver, if set to false, openning RolesManage page will get exception such as

InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.

And if i use MySql, there's no way to set MultipleActiveResultSets=true(not supported at all, web app cannot start).

So I think somewhere in UserRolesController.cs could be improved to avoid this exception.
But I'm not yet able to fix myself. Could you have a look?

InvalidOperationException: Role BASIC does not exist.

Ho, i dowloaded your code an try to fill my first us by using the registration form and when i send it i got this error :
InvalidOperationException: Role BASIC does not exist.
Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore<TUser, TRole, TContext, TKey, TUserClaim, TUserRole, TUserLogin, TUserToken, TRoleClaim>.AddToRoleAsync(TUser user, string normalizedRoleName, CancellationToken cancellationToken)
Microsoft.AspNetCore.Identity.UserManager.AddToRoleAsync(TUser user, string role)
UserManagement.MVC.Areas.Identity.Pages.Account.RegisterModel.OnPostAsync(string returnUrl) in Register.cshtml.cs
+
await _userManager.AddToRoleAsync(user, Enums.Roles.Basic.ToString());
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory+GenericTaskHandlerMethod.Convert(object taskAsObject)
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory+GenericTaskHandlerMethod.Execute(object receiver, object[] arguments)
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeHandlerMethodAsync()
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeNextPageFilterAsync()
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Rethrow(PageHandlerExecutedContext context)
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Doesn't work out of the box

@iammukeshm I am not sure if you are checking these or planning on updating the repo to make it more current and useful, but thought since I spent some time with it, although disappointed that it doesn't work, wanted to let you know. Hopefully these are not out there just to get views and drive ad revenue and sincerely intended to be educational and useful.

Out of the box

image

The project is also targeting 3.1 which is end of life, out of support and has security vulnerabilities. It would be helpful if you updated it for .NET 6 (LTS) or even .NET 7 (STS) as enough changes have been introduced to make the tutorial somewhat obsolete.

Support MultipleActiveResultSets=false?

This demo is great and I want to integrate the role manage functions in my project.

In connection string, MultipleActiveResultSets=true is a feature of sqlserver, if set to false, openning RolesManage page will get exception such as

InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.

image

And if i use MySql, there's no way to set MultipleActiveResultSets=true(not supported at all, web app cannot start).

So I think somewhere in UserRolesController.cs could be improved to avoid this exception.
But I'm not yet able to fix myself. Could you have a look?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.