简体   繁体   中英

encrypting username in asp.net mvc5 login

I want to encrypt the username for the login of an asp.net mvc5 site. When the controller calls var result = await UserManager.CreateAsync(user,model.Password); to register a new user, I get an error telling me

User name abc/12&3== is invalid, can only contain letters or digits.

I'm guessing I cannot make this function take these non-alphanumeric values, so how can I make an AES encrypted value fall within the guidelines?

Thanks, Dave K.

You seem to have found a way to hack around this but the real problem is just that you need to change the user validator:

UserManager.UserValidator = new UserValidator<ApplicationUser>(UserManager) 
  {
    AllowOnlyAlphanumericUserNames = false,
  };

找到可以在其他帖子上使用的内容,将值转换为Base36

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM