Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用以下代码打印用户名。
@if (User.Identity.IsAuthenticated) { @Html.Display("Welcome, " + User.Identity.Name); }
但它不打印它。
为什么?
Html.Display不是要显示字符串,而是模型中的属性。尝试这样的事情:
Html.Display
@if (User.Identity.IsAuthenticated) { @: Welcome, @User.Identity.Name }
我找到了另一个解决方案:
@if (User.Identity.IsAuthenticated) { <label>Welcome, </label> @Html.Label(User.Identity.Name); }