Reputation: 418
Which is the best way to expose current logged in user data to many different views?
I am thinking something like the Model variable but accessible to all view but wasn't able to find any documentation.
Upvotes: 0
Views: 371
Reputation: 16398
You an access the user property from any view with
@User
For example (C#),
@{
if (User.Identity.IsAuthenticated)
{
<p>Hello, @User.Identity.Name</p>
}
}
Upvotes: 1