Google+ Peter Bromberg's .NET Blog | All posts tagged 'MVC'

Peter Bromberg's .NET Blog All Things Programming

How to get the logged in user's first and last name with Auth0

13. June 2017 15:20 by admin in

Sample code:

public ActionResult Index()

        {

            var nameClaim = ClaimsPrincipal.Current.FindFirst("name");

            if (nameClaim != null && !string.IsNullOrEmpty(nameClaim.Value))

            {

                var welcomeName = ClaimsPrincipal.Current.FindFirst("given_name").Value + " " 

                    + ClaimsPrincipal.Current.FindFirst("family_name").Value;              

                ViewBag.Name = welcomeName;  

            }

            return View();

       }