我如何在mvc 4中的_loginpartial.cshtml文件中显示自定义字段名称

时间:2014-12-03 12:54:12

标签: asp.net-mvc-4

我如何更换

@if (Request.IsAuthenticated) {
<text>
    Hello, @Html.ActionLink(User.Identity.Name, "Manage", "Account", routeValues: null, htmlAttributes: new { @class = "username", title = "Manage" })!
    @using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" })) {
        @Html.AntiForgeryToken()
        <a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>
    }
</text>

} else {     

    <li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
    <li>@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })</li>
</ul>

}

我的名字存储在mvc 4中的userprofile表中

1 个答案:

答案 0 :(得分:0)

您需要将User.Identity.Name替换为Model.Firstname,假设您可以访问包含其中第一个名称的模型。