当前位置: 代码迷 >> VC/MFC >> MVC5 Identity 用用户名登录而不要电子邮件
  详细解决方案

MVC5 Identity 用用户名登录而不要电子邮件

热度:271   发布时间:2016-05-02 03:53:02.0
MVC5 Identity 用用户名登录而不用电子邮件
1、修改AccountViewModels
·修改RegisterViewModel
public class RegisterViewModel{    [Required]    [Display(Name = "用户名")]    public string UserName { get; set; }    .......}

·修改LoginViewModel

public class LoginViewModel{    [Required]    [Display(Name = "用户名")]    public string UserName { get; set; }    [Required]    [DataType(DataType.Password)]    [Display(Name = "密码")]    public string Password { get; set; }    [Display(Name = "记住我?")]    public bool RememberMe { get; set; }}
2、修改AccountController
修改注册页面控制器
var user = new ApplicationUser { UserName = model.UserName, Email = model.Email};
修改登录页面控制器
var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false);

3、修改页面

完成

  相关解决方案