Asp.net mvc 4 如何在mvc4中的_loginpartial.chtml文件中显示自定义字段名

Asp.net mvc 4 如何在mvc4中的_loginpartial.chtml文件中显示自定义字段名,asp.net-mvc-4,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",

如何替换

@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>
@if(Request.IsAuthenticated){
您好,@Html.ActionLink(User.Identity.Name,“Manage”,“Account”,routeValue:null,htmlAttributes:new{@class=“username”,title=“Manage”})!
@使用(Html.BeginForm(“注销”、“帐户”、FormMethod.Post、新{id=“logoutForm”})){
@Html.AntiForgeryToken()
}
}否则{

ActionLink(“Register”、“Register”、“Account”、routeValue:null、htmlAttributes:new{id=“registerLink”})
  • @ActionLink(“登录”、“登录”、“帐户”、routeValue:null、htmlAttributes:new{id=“loginLink”})
  • }


    使用存储在mvc 4的userprofile表中的我的名字,您需要将
    User.Identity.Name
    替换为
    Model.Firstname
    ,假设您可以访问其中包含名字的模型。

    请告诉我如何访问我正在使用@Model的_loginpartial-chtml文件中的模型ScoreMyOffer.Domain.ViewModels.ManageUserProfileViewModel但这不起作用i am add@Model=>Model.FirstName但它显示“外部组件引发了异常”。如果您只执行Model.FirstName,会发生什么?如果您将所有代码也包含在原始问题中,可能会更容易!
        <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>