Reputation: 37672
I use the following code to print user name.
@if (User.Identity.IsAuthenticated)
{
@Html.Display("Welcome, " + User.Identity.Name);
}
But it doesn't print it.
Why?
Upvotes: 0
Views: 87
Reputation: 37672
I found another solution:
@if (User.Identity.IsAuthenticated)
{
<label>Welcome, </label> @Html.Label(User.Identity.Name);
}
Upvotes: 0
Reputation: 75699
Html.Display
is not meant to display strings, but properties from your model. Try something like this:
@if (User.Identity.IsAuthenticated)
{
@: Welcome, @User.Identity.Name
}
Upvotes: 4