3

My mvc5 application uses aspnet.identity authentication. Owin middleware is configured to use application cookies. All i want to achieve is to show user full name instead of the login in the LoginPartial view.

@Html.ActionLink("Hello, " + User.Identity.GetUserName() + "!", "Manage", "Account", routeValues: null, htmlAttributes: new { title = "Manage" })

I guess i need to customize my identity during creating it with user manager. Am I right?

    private async Task SignInAsync(ApplicationUser user, bool isPersistent)
    {
        var identity = await userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);

        AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
    }

I know I can store it in the session but what is the right way to store additional information?

Coffka
  • 749
  • 1
  • 8
  • 23
  • My answer here is a short guide on adding claims to the identity token. http://stackoverflow.com/questions/27683169/identity-2-0-creating-custom-claimsidentity-eg-user-identity-getuserbyidint/27694574#27694574 – jamesSampica Apr 09 '15 at 03:55

1 Answers1

1

You can use claims to store the user's full name. Here is an article on how to add and retrieve custom claims using ASP.NET Identity.

Kevin Junghans
  • 17,475
  • 4
  • 45
  • 62