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.
我正在寻找在布局文件的标题中显示当前用户名。实现这一目标的最佳方法是什么?我目前没有将任何模型传递到布局文件中。另外,如果没有人登录,我不想明显显示用户名
它_LogOnPartial.cshtml在默认模板的视图上!
_LogOnPartial.cshtml
@if(Request.IsAuthenticated) { <text>Welcome <b>@Context.User.Identity.Name</b>! [ @Html.ActionLink("Log Off", "LogOff", "Account") ]</text> } else { @:[ @Html.ActionLink("Log On", "LogOn", "Account") ] }