Displaying User Full Name instead of User Email in Asp.net Identity 2.0

I would like to display the users full name instead of email address

right now to display the email address the code is  Hello, <%: Context.User.Identity.GetUserName()  %>

I added a field into the user table AspNetUsers - FullName  and want to pull the value of that field for the user and display instead of the GetUserName()

Thanks
dkilbyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Randy DownsOWNERCommented:
Try

 <%: Context.User.Identity.FullName()  %>

Open in new window

dkilbyAuthor Commented:
i get the below error when using the above code

Error      3      'System.Security.Principal.IIdentity' does not contain a definition for 'FullName' and no extension method 'FullName' accepting a first argument of type 'System.Security.Principal.IIdentity' could be found (are you missing a using directive or an assembly reference?)      c:\Users\Dave\Documents\Visual Studio 2013\Projects\Tracker\Tracker\Site.Master      67      140      Tracker
Randy DownsOWNERCommented:
Try this.

AspNet Identity 2.0 with MVC 5 by default displays the username which is user's email address in  _LoginPartial.cshtml page.  I will go through how to change this to user's FirstName and LastName  i.e. Full Name
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

dkilbyAuthor Commented:
the example is for MVC 5, which unfortunately i am not familiar with, i am using webforms is there a way to convert that logic to work in a webform ?
Randy DownsOWNERCommented:
Maybe you can adapt this.

class
namespace ParameterDemo {
    public class LoginParameter : Parameter {
        public LoginParameter(string name)
            : base(name)
        {}

        protected override object Evaluate(HttpContext context, Control control)
        {
            //UPDATED as suggested in Joels comments below...
            //return HttpContext.Current.User.Identity.Name;
            return context.Current.User.Identity.Name;
        }
    }
}

Open in new window


register
<%@ Register TagPrefix="put" Namespace="ParameterDemo" %>

Open in new window


pull data
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
    SelectCommand="SELECT * FROM MyTable WHERE SomeValue=@SomeParameter">
    <SelectParameters>
        <put:loginParameter name="SomeParameter" />
    </SelectParameters>
</asp:ObjectDataSource>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dkilbyAuthor Commented:
Thanks for the help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.