concept new claim in category asp.net

This is an excerpt from Manning's book ASP.NET Core in Action.
Table 14.1. Which services are and aren’t handled by ASP.NET Core Identity
Managed by ASP.NET Core Identity
Implemented by the developer
Database schema for storing users and claims. UI for logging in, creating, and managing users (controller, actions, view models). This is included in the default templates. Creating a user in the database. Sending emails and SMS messages. Password validation and rules. Customizing claims for users (adding new claims). Handling user account lockout (to prevent brute-force attacks). Configuring third-party identity providers. Managing and generating 2FA codes. Generating password-reset tokens. Saving additional claims to the database. Managing third-party identity providers (for example Facebook, Google, Twitter).
In this section, I show you the first approach, automatically adding new claims to a user when they’re created. The latter approach is the more flexible and, ultimately, is the approach many apps will need, especially line-of-business apps. Luckily, there’s nothing conceptually difficult to it; it requires a simple UI that lets you view users and add a claim through the same mechanism I’ll show here.
Listing 14.10. Adding a custom claim to a new user in the Register action
public async Task<IActionResult> Register( RegisterViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { var user = new ApplicationUser { #1 UserName = model.Email, Email = model.Email }; #1 var result = await _userManager.CreateAsync( #2 user, model.Password); #2 if (result.Succeeded) { var claim = new Claim("FullName", model.Name); #3 await _userManager.AddClaimAsync(user, nameClaim); #4 await _signInManager.SignInAsync(user); #5 return RedirectToLocal(returnUrl); } AddErrors(result); } return View(model); } #1 Creates an instance of the ApplicationUser entity, as usual #2 Validates that the provided password is valid and creates the user in the database #3 Creates a claim, with a string name of “FullName” and the provided value #4 Adds the new claim to the ApplicationUser’s collection #5 Signs the user in by setting the HttpContext.User, the principal will include the custom claim !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":6,\"ch\":67},{\"line\":6,\"ch\":69}],[{\"line\":7,\"ch\":67},{\"line\":7,\"ch\":69}],[{\"line\":25,\"ch\":0},{\"line\":25,\"ch\":2}],[{\"line\":6,\"ch\":67},{\"line\":6,\"ch\":69}],[{\"line\":7,\"ch\":67},{\"line\":7,\"ch\":69}],[{\"line\":25,\"ch\":0},{\"line\":25,\"ch\":2}],[{\"line\":8,\"ch\":67},{\"line\":8,\"ch\":69}],[{\"line\":9,\"ch\":67},{\"line\":9,\"ch\":69}],[{\"line\":26,\"ch\":0},{\"line\":26,\"ch\":2}],[{\"line\":8,\"ch\":67},{\"line\":8,\"ch\":69}],[{\"line\":9,\"ch\":67},{\"line\":9,\"ch\":69}],[{\"line\":26,\"ch\":0},{\"line\":26,\"ch\":2}],[{\"line\":13,\"ch\":12},{\"line\":13,\"ch\":58}],[{\"line\":13,\"ch\":67},{\"line\":13,\"ch\":69}],[{\"line\":27,\"ch\":0},{\"line\":27,\"ch\":2}],[{\"line\":14,\"ch\":12},{\"line\":14,\"ch\":62}],[{\"line\":14,\"ch\":67},{\"line\":14,\"ch\":69}],[{\"line\":28,\"ch\":0},{\"line\":28,\"ch\":2}],[{\"line\":16,\"ch\":67},{\"line\":16,\"ch\":69}],[{\"line\":29,\"ch\":0},{\"line\":29,\"ch\":2}]]"} !@%STYLE%@!This is all that’s required to add the new claim, but you’re not using it anywhere currently. What if you want to display it? Well, you’ve added a claim to the user principal, which was assigned to the HttpContext.User property when you called SignInAsync. That means you can access the claims anywhere you have access to HttpContext—in your controllers or in view templates. For example, you could display the user’s FullName claim anywhere in a Razor template with the following statement: