我得到这个工作。
首先去 accountViewModels 并为 UserName 添加一个 Property
Public Class RegisterViewModel
<Required>
<Display(Name:="User Name")>
Public Property UserName As String
<Required>
<EmailAddress>
<Display(Name:="Email")>
Public Property Email As String
修改您的注册视图后添加用户名属性
<div class="form-group">
@Html.LabelFor(Function(m) m.UserName, New With {.class = "col-md-2 control-label"})
<div class="col-md-10">
@Html.TextBoxFor(Function(m) m.UserName, New With {.class = "form-control"})
</div>
</div>
<div class="form-group">
@Html.LabelFor(Function(m) m.Email, New With {.class = "col-md-2 control-label"})
<div class="col-md-10">
@Html.TextBoxFor(Function(m) m.Email, New With {.class = "form-control"})
</div>
</div>
完成后,修改您的登录视图
@Html.ValidationSummary(True, "", New With {.class = "text-danger"})
<div class="form-group">
@Html.Label("User Name", New With {.class = "col-md-2 control-label"})
<div class="col-md-10">
@Html.TextBoxFor(Function(m) m.Email, New With {.class = "form-control"})
@Html.ValidationMessageFor(Function(m) m.Email, "", New With {.class = "text-danger"})
</div>
</div>
<div class="form-group">
@Html.LabelFor(Function(m) m.Password, New With {.class = "col-md-2 control-label"})
<div class="col-md-10">
@Html.PasswordFor(Function(m) m.Password, New With {.class = "form-control"})
@Html.ValidationMessageFor(Function(m) m.Password, "", New With {.class = "text-danger"})
</div>
</div>
这就是你所需要的。这样您就可以使用用户名而不是电子邮件地址登录。