liveBook · Manning

UserManager<T>

As explained in ASP.NET Core in Action, 3e

UserManager<T> is an ASP.NET Core Identity service for creating, retrieving, updating, and managing users and their associated credentials and data.

UserManager<T> is the ASP.NET Core Identity service for working with user accounts. It can create accounts, load users from the database, change passwords, and add claims. SignInManager<T> handles signing users in and out, while UserManager<T> handles much of the account data and credential work. section 23.7

A registration handler typically creates an ApplicationUser, supplies the password to CreateAsync, and checks the result. After a successful creation, AddClaimAsync can attach application data such as a FullName claim. Claims become available through HttpContext.User after sign-in. section 23.6 section 23.7

Add a claim during registration

Create the user with _userManager.CreateAsync(user, Input.Password), then create new Claim("FullName", Input.Name) and pass it to _userManager.AddClaimAsync(user, claim). The handler can then generate an email-confirmation token and send the confirmation message. Later, display the value with User.FindFirstValue("FullName"). section 23.6

UserManager<T> supplies the service layer, not the complete user interface. The application must provide or enable the pages and endpoints, protect permission-editing pages appropriately, and configure Identity features such as email confirmation or multifactor authentication when needed. section 23.6 section 23.7

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains account creation and claim assignment with a simplified handler, while deferring complete UI, validation, and production boilerplate.
Examples
Uses ApplicationUser registration, a FullName claim, email confirmation, and Razor expressions that retrieve the claim value.
What it assumes
Assumes an Identity application with an ApplicationUser and registration handler, while treating the default UI and database wiring as configurable setup.
What you can do after
Apply it via ASP.NET Core Identity to create users, attach claims, generate confirmation tokens, and read claims after sign-in.
How it connects
Connects UserManager<T> with ASP.NET Core Identity, SignInManager<T>, claims, HttpContext.User, IdentityDbContext<TUser>, and EF Core.

Also explained in

Compare how 3 books explain UserManager<T> →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.