how to get current user name in razor page

lawrence whittemore asked on September 22, 2022 21:34

How do I access the current users info, specifically their first and last name through the cshtml page?

Correct Answer

Dmitry Bastron answered on September 30, 2022 09:33

Hi Lawrence,

Please refer to the bottom of this support article:

Tip: When writing additional code or views for your website, you can access information about the currently authenticated user via the User property. For example, User.Identity.Name returns the username of the currently signed-in user.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Petrinec answered on September 23, 2022 09:43 (last edited on September 23, 2022 09:44)

Hi Lawrence, you can use:

@using CMS.Membership

<p>@MembershipContext.AuthenticatedUser.FirstName</p>
1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.