In ASP.NET core by default logged in user’s email is shown in header after login.

We can show any other information like First or Last Name or even full name (by combining these two).

To achieve this we need to make the following changes:

Customize your Identity User

Customize the identity user and identity role (if needed) as shown below:

 public class ApplicationUser: IdentityUser<int>
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
public class ApplicationRole : IdentityRole<int>
    {
        //add fields here
    }

Apply
 ...  read more

In previous articles Get enumeration items as a list in C# and Populate dropdown with enumeration items in ASP.NET Core we that saw how to get enumeration items as a collection to bind it to data controls like dropdown etc.
In this article we will see that how can we get the description given as an attribute with an item. We may need this information on various places, say we have listing of users and we need to show each user’s status but in a descriptive way.

Here is our example enumeration:

  enum UserStatus
    {
        [Description("Pending Verification")]
        PendingVerification = 1,
        [Description("Pending Admin Approval")]
        PendingAdminApproval = 2,
        [Description("Active")]
     
 ...  read more

We can bind a dropdown with enumeration items without creating a look up table.

In Get enumeration items as a list in C# article we saw that how we can get enumeration items as a list to bind it to a data control.

Here is the enumeration we have been working with:

 enum UserStatus
    {
        [Description("Pending Verification")]
        PendingVerification = 1,
        [Description("Pending Admin Approval")]
        PendingAdminApproval = 2,
        [Description("Active")]
      
 ...  read more