User657329123 posted
Hi there,
I'm adding a claim like this in my controller
UserPrincipal principal = UserPrincipal.FindByIdentity(context, model.UserName);
firstName = principal.GivenName;
await UserManager.AddClaimAsync(user.Id, new Claim("first_name", firstName));
In my View, I'm trying to access first_name claim like this
@Html.ActionLink("Hello " + ((ClaimsIdentity)User.Identity).FindFirst("first_name").Value + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
but getting exception System.NullReferenceException: 'Object reference not set to an instance of an object.' In my view, I have added
@using Microsoft.AspNet.Identity;
@using System.Security.Claims;
What am I doing wrong?
Joe